]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
alembic: Remove batch operations (and sqlite support) 46/2546/2
authorGeorge Joseph <george.joseph@fairview5.com>
Thu, 7 Apr 2016 16:49:43 +0000 (10:49 -0600)
committerGeorge Joseph <george.joseph@fairview5.com>
Thu, 7 Apr 2016 18:36:10 +0000 (13:36 -0500)
Because SQLite doesn't support full ALTER capabilities, alembic scripts
require batch operations.  However, that capability wasn't available until
0.7.0 which some distributions haven't reached yet.  Therefore, the batch
operations introduced in commit 86d6e44cc (review 2319) have been reverted
and SQLite is unsupported again, for now anyway.

Tested the full upgrade and downgrade on MySQL/Mariadb and Postgresql.

ASTERISK-25890 #close
Reported-by: Harley Peters
Change-Id: I82eba5456736320256f6775f5b0b40133f4d1c80

33 files changed:
contrib/ast-db-manage/config/env.py
contrib/ast-db-manage/config/versions/10aedae86a32_add_outgoing_enum_va.py
contrib/ast-db-manage/config/versions/136885b81223_add_regcontext_to_pj.py
contrib/ast-db-manage/config/versions/154177371065_add_default_from_user.py
contrib/ast-db-manage/config/versions/1758e8bbf6b_increase_useragent_column_size.py
contrib/ast-db-manage/config/versions/189a235b3fd7_add_keep_alive_interval.py
contrib/ast-db-manage/config/versions/1c688d9a003c_pjsip_voicemail_extension.py
contrib/ast-db-manage/config/versions/1d50859ed02e_create_accountcode.py
contrib/ast-db-manage/config/versions/21e526ad3040_add_pjsip_debug_option.py
contrib/ast-db-manage/config/versions/23530d604b96_add_rpid_immediate.py
contrib/ast-db-manage/config/versions/26d7f3bf0fa5_add_bind_rtp_to_media_address_to_pjsip.py
contrib/ast-db-manage/config/versions/26f10cadc157_add_pjsip_timeout_options.py
contrib/ast-db-manage/config/versions/28b8e71e541f_add_g726_non_standard.py
contrib/ast-db-manage/config/versions/28ce1e718f05_add_fatal_response_interval.py
contrib/ast-db-manage/config/versions/2d078ec071b7_increaes_contact_column_size.py
contrib/ast-db-manage/config/versions/2fc7930b41b3_add_pjsip_endpoint_options_for_12_1.py
contrib/ast-db-manage/config/versions/31cd4f4891ec_add_auto_dtmf_mode.py
contrib/ast-db-manage/config/versions/371a3bf4143e_add_user_eq_phone_option_to_pjsip.py
contrib/ast-db-manage/config/versions/3855ee4e5f85_add_missing_pjsip_options.py
contrib/ast-db-manage/config/versions/3bcc0b5bc2c9_add_allow_reload_to_ps_transports.py
contrib/ast-db-manage/config/versions/423f34ad36e2_fix_pjsip_qualify_ti.py
contrib/ast-db-manage/config/versions/45e3f47c6c44_add_pjsip_endpoint_identifier_order.py
contrib/ast-db-manage/config/versions/461d7d691209_add_pjsip_qualify_timeout.py
contrib/ast-db-manage/config/versions/498357a710ae_add_rtp_keepalive.py
contrib/ast-db-manage/config/versions/4c573e7135bd_fix_tos_field_types.py
contrib/ast-db-manage/config/versions/5139253c0423_make_q_member_uniqueid_autoinc.py
contrib/ast-db-manage/config/versions/51f8cb66540e_add_further_dtls_options.py
contrib/ast-db-manage/config/versions/5813202e92be_add_contact_expiration_check_interval_.py
contrib/ast-db-manage/config/versions/5950038a6ead_fix_pjsip_verifiy_typo.py
contrib/ast-db-manage/config/versions/a541e0b5e89_add_pjsip_max_initial_qualify_time.py
contrib/ast-db-manage/config/versions/dbc44d5a908_add_missing_columns_to_sys_and_reg.py
contrib/ast-db-manage/config/versions/e96a0b8071c_increase_pjsip_column_size.py
contrib/ast-db-manage/config/versions/eb88a14f2a_add_media_encryption_optimistic_to_pjsip.py

index 4118da06681656eaa28c662730af023b6390df6c..6740d5906d532e5b34fc3f9dae80641289ff5f7f 100755 (executable)
@@ -58,8 +58,7 @@ def run_migrations_online():
     connection = engine.connect()
     context.configure(
                 connection=connection,
-                target_metadata=target_metadata,
-                render_as_batch=True
+                target_metadata=target_metadata
                 )
 
     try:
index cc9f0e0cc1d2e02247411f71222bab538424c418..b4ea71cbd01406eac52206e387f5830002b3b9ac 100755 (executable)
@@ -45,10 +45,7 @@ def upgrade():
     context = op.get_context()
 
     # Upgrading to this revision WILL clear your directmedia values.
-    if context.bind.dialect.name == 'sqlite':
-        with op.batch_alter_table('sippeers') as batch_op:
-            batch_op.alter_column('directmedia', type_=new_type)
-    elif context.bind.dialect.name != 'postgresql':
+    if context.bind.dialect.name != 'postgresql':
         op.alter_column('sippeers', 'directmedia',
                         type_=new_type,
                         existing_type=old_type)
@@ -69,10 +66,7 @@ def downgrade():
     op.execute(tcr.update().where(tcr.c.directmedia==u'outgoing')
                .values(directmedia=None))
 
-    if context.bind.dialect.name == 'sqlite':
-        with op.batch_alter_table('sippeers') as batch_op:
-            batch_op.alter_column('directmedia', type_=old_type)
-    elif context.bind.dialect.name != 'postgresql':
+    if context.bind.dialect.name != 'postgresql':
         op.alter_column('sippeers', 'directmedia',
                         type_=old_type,
                         existing_type=new_type)
index 22fd6c7b740b60af8e8fe58502bae4d9206aa43b..724a5e57695296f44528761ef08e1bb25af09f89 100644 (file)
@@ -17,5 +17,4 @@ def upgrade():
     op.add_column('ps_globals', sa.Column('regcontext', sa.String(80)))
 
 def downgrade():
-    with op.batch_alter_table('ps_globals') as batch_op:
-        batch_op.drop_column('regcontext')
+    op.drop_column('ps_globals', 'regcontext')
index 6c5f808bba7535f60985ceb4993401c62a4b8c10..7e6cf994f6162cd53e2457cabfc232d1ed25d119 100644 (file)
@@ -19,5 +19,4 @@ def upgrade():
 
 
 def downgrade():
-    with op.batch_alter_table('ps_globals') as batch_op:
-        batch_op.drop_column('default_from_user')
+    op.drop_column('ps_globals', 'default_from_user')
index c16cff9f4a8361c12168dbec02544cb55f5dbb9c..215726fa059b6a24cf18cdef659135025af07cc3 100755 (executable)
@@ -33,11 +33,9 @@ import sqlalchemy as sa
 
 
 def upgrade():
-    with op.batch_alter_table('sippeers') as batch_op:
-        batch_op.alter_column('useragent', type_=sa.String(255))
+    op.alter_column('sippeers', 'useragent', type_=sa.String(255))
 
 
 def downgrade():
-    with op.batch_alter_table('sippeers') as batch_op:
-        batch_op.alter_column('useragent', type_=sa.String(20))
+    op.alter_column('sippeers', 'useragent', type_=sa.String(20))
 
index da22f261b39743cf215c08cce5d75c74cbc846f8..aa52171f85dacfee5c81106009e1662f16bc42e9 100644 (file)
@@ -19,5 +19,4 @@ def upgrade():
 
 
 def downgrade():
-    with op.batch_alter_table('ps_globals') as batch_op:
-        batch_op.drop_column('keep_alive_interval')
+    op.drop_column('ps_globals', 'keep_alive_interval')
index 781dca703ba9d90adb1a2b4fb8c66358a9e43808..e6f917d87082b7d6f11ae5d8a21049fda09f1e63 100644 (file)
@@ -22,10 +22,7 @@ def upgrade():
 
 
 def downgrade():
-    with op.batch_alter_table('ps_globals') as batch_op:
-        batch_op.drop_column('default_voicemail_extension')
-    with op.batch_alter_table('ps_aors') as batch_op:
-        batch_op.drop_column('voicemail_extension')
-    with op.batch_alter_table('ps_endpoints') as batch_op:
-        batch_op.drop_column('voicemail_extension')
-        batch_op.drop_column('mwi_subscribe_replaces_unsolicited')
+    op.drop_column('ps_globals', 'default_voicemail_extension')
+    op.drop_column('ps_aors', 'voicemail_extension')
+    op.drop_column('ps_endpoints', 'voicemail_extension')
+    op.drop_column('ps_endpoints', 'mwi_subscribe_replaces_unsolicited')
index 4d520fcee6c38b57e9cbebb4e81a939dbd9595c4..eb200013788e1ee851e73a84b8cc38aae4dbcd78 100644 (file)
@@ -17,5 +17,4 @@ def upgrade():
     op.add_column('ps_endpoints', sa.Column('accountcode', sa.String(20)))
 
 def downgrade():
-    with op.batch_alter_table('ps_endpoints') as batch_op:
-        batch_op.drop_column('accountcode')
+    op.drop_column('ps_endpoints', 'accountcode')
index 8b77eb7ac619d133f3fc765aaf605515f664404c..2adca628b51b18fa2e14c8c7e624ed263a99d927 100755 (executable)
@@ -18,5 +18,4 @@ def upgrade():
     op.add_column('ps_globals', sa.Column('debug', sa.String(40)))
 
 def downgrade():
-    with op.batch_alter_table('ps_globals') as batch_op:
-        batch_op.drop_column('debug')
+    op.drop_column('ps_globals', 'debug')
index 8ca63f1487c1f9f3bb9e04a9499786019a8a792c..dc0c01c24c3048b5ddbc775c5efb912e70a16fe8 100755 (executable)
@@ -45,5 +45,4 @@ def upgrade():
     op.add_column('ps_endpoints', sa.Column('rpid_immediate', yesno_values))
 
 def downgrade():
-    with op.batch_alter_table('ps_endpoints') as batch_op:
-        batch_op.drop_column('rpid_immediate')
+    op.drop_column('ps_endpoints', 'rpid_immediate')
index 1199d0c8380edc844ff46940a04e329705343cb6..e7c11da19259133cc38cd5b5eddca1d489078243 100644 (file)
@@ -28,5 +28,4 @@ def upgrade():
 
 
 def downgrade():
-    with op.batch_alter_table('ps_endpoints') as batch_op:
-        batch_op.drop_column('bind_rtp_to_media_address')
+    op.drop_column('ps_endpoints', 'bind_rtp_to_media_address')
index 2a792d3f1e91631b3f1b5f30da2f9e59dfbc27a0..8972d80302aa5a0424bd6fa7b411f89882d61164 100644 (file)
@@ -20,6 +20,5 @@ def upgrade():
 
 
 def downgrade():
-    with op.batch_alter_table('ps_endpoints') as batch_op:
-        batch_op.drop_column('rtp_timeout')
-        batch_op.drop_column('rtp_timeout_hold')
+    op.drop_column('ps_endpoints', 'rtp_timeout')
+    op.drop_column('ps_endpoints', 'rtp_timeout_hold')
index 09056d6c40872190fd784b5b57f4a6114753eb2d..ad36bd9b7cd3c3b87271caf34532a8ba03687832 100644 (file)
@@ -27,5 +27,4 @@ def upgrade():
 
 
 def downgrade():
-    with op.batch_alter_table('ps_endpoints') as batch_op:
-        batch_op.drop_column('g726_non_standard')
+    op.drop_column('ps_endpoints', 'g726_non_standard')
index 8e05a62a4c2e07e0315c1cc56ddd256c55e7b5f7..8c499aee8c250f1ef41213228c2cf352fa1ec13d 100644 (file)
@@ -19,5 +19,4 @@ def upgrade():
 
 
 def downgrade():
-    with op.batch_alter_table('ps_registrations') as batch_op:
-        batch_op.drop_column('fatal_retry_interval')
+    op.drop_column('ps_registrations', 'fatal_retry_interval')
index 9f98750f615323ec41474c108ecaf5ee2509f7c2..2ade86f9f3de842a55fe200923b1186655e619e6 100644 (file)
@@ -15,10 +15,8 @@ import sqlalchemy as sa
 
 
 def upgrade():
-    with op.batch_alter_table('ps_aors') as batch_op:
-        batch_op.alter_column('contact', type_=sa.String(255))
+    op.alter_column('ps_aors', 'contact', type_=sa.String(255))
 
 
 def downgrade():
-    with op.batch_alter_table('ps_aors') as batch_op:
-        batch_op.alter_column('contact', type_=sa.String(40))
+    op.alter_column('ps_aors', 'contact', type_=sa.String(40))
index 102265ea84ac3b608ad48202263def6a3f35d5cc..d39ddb41a59be7870974aa9ceac0988ffb08402e 100755 (executable)
@@ -120,17 +120,15 @@ def upgrade():
     op.create_index('ps_registrations_id', 'ps_registrations', ['id'])
 
     ########################## add columns ###########################
-    with op.batch_alter_table('ps_endpoints') as batch_op:
     # new columns for endpoints
-        batch_op.add_column(sa.Column('media_address', sa.String(40)))
-        batch_op.add_column(sa.Column('redirect_method',
-                                            pjsip_redirect_method_values))
-        batch_op.add_column(sa.Column('set_var', sa.Text()))
+    op.add_column('ps_endpoints', sa.Column('media_address', sa.String(40)))
+    op.add_column('ps_endpoints', sa.Column('redirect_method',
+        pjsip_redirect_method_values))
+    op.add_column('ps_endpoints', sa.Column('set_var', sa.Text()))
 
     # rename mwi_fromuser to mwi_from_user
-        batch_op.alter_column('mwi_fromuser',
-                    new_column_name='mwi_from_user',
-                    existing_type=sa.String(40))
+    op.alter_column('ps_endpoints', 'mwi_fromuser',
+        new_column_name='mwi_from_user', existing_type=sa.String(40))
 
     # new columns for contacts
     op.add_column('ps_contacts', sa.Column('outbound_proxy', sa.String(40)))
@@ -144,23 +142,19 @@ def upgrade():
 def downgrade():
     ########################## drop columns ##########################
 
-    with op.batch_alter_table('ps_aors') as batch_op:
-        batch_op.drop_column('support_path')
-        batch_op.drop_column('outbound_proxy')
-        batch_op.drop_column('maximum_expiration')
+    op.drop_column('ps_aors', 'support_path')
+    op.drop_column('ps_aors', 'outbound_proxy')
+    op.drop_column('ps_aors', 'maximum_expiration')
 
-    with op.batch_alter_table('ps_contacts') as batch_op:
-        batch_op.drop_column('path')
-        batch_op.drop_column('outbound_proxy')
+    op.drop_column('ps_contacts', 'path')
+    op.drop_column('ps_contacts', 'outbound_proxy')
 
-    with op.batch_alter_table('ps_endpoints') as batch_op:
-        batch_op.alter_column('mwi_from_user',
-                    new_column_name='mwi_fromuser',
-                    existing_type=sa.String(40))
+    op.alter_column('ps_endpoints', 'mwi_from_user',
+        new_column_name='mwi_fromuser', existing_type=sa.String(40))
 
-        batch_op.drop_column('set_var')
-        batch_op.drop_column('redirect_method')
-        batch_op.drop_column('media_address')
+    op.drop_column('ps_endpoints', 'set_var')
+    op.drop_column('ps_endpoints', 'redirect_method')
+    op.drop_column('ps_endpoints', 'media_address')
 
     ########################## drop tables ###########################
 
index b1a9f8be8edda701f61d9adbca2ec7c7aa75c3f7..778de8f37a79c60974e4f21a40456386151a6d33 100644 (file)
@@ -24,10 +24,7 @@ def upgrade():
     context = op.get_context()
 
     # Upgrading to this revision WILL clear your directmedia values.
-    if context.bind.dialect.name == 'sqlite':
-        with op.batch_alter_table('ps_endpoints') as batch_op:
-            batch_op.alter_column('dtmf_mode', type_=new_type)
-    elif context.bind.dialect.name != 'postgresql':
+    if context.bind.dialect.name != 'postgresql':
         op.alter_column('ps_endpoints', 'dtmf_mode',
                         type_=new_type,
                         existing_type=old_type)
@@ -45,10 +42,7 @@ def upgrade():
 def downgrade():
     context = op.get_context()
 
-    if context.bind.dialect.name == 'sqlite':
-        with op.batch_alter_table('ps_endpoints') as batch_op:
-            batch_op.alter_column('dtmf_mode', type_=old_type)
-    elif context.bind.dialect.name != 'postgresql':
+    if context.bind.dialect.name != 'postgresql':
         op.alter_column('ps_endpoints', 'dtmf_mode',
                         type_=old_type,
                         existing_type=new_type)
index bb65874d6b406f797e1feef49effc92fddba9ac9..ea2b291de36a76cbf2244850e121cf3a93c189f9 100644 (file)
@@ -27,5 +27,4 @@ def upgrade():
     op.add_column('ps_endpoints', sa.Column('user_eq_phone', yesno_values))
 
 def downgrade():
-    with op.batch_alter_table('ps_endpoints') as batch_op:
-        batch_op.drop_column('user_eq_phone')
+    op.drop_column('ps_endpoints', 'user_eq_phone')
index 08457a9d8c6b3afcc218f8ae14c81b027a88f835..afc1beb3775ffaf2bf67705331e92758f2dd28cb 100644 (file)
@@ -20,7 +20,5 @@ def upgrade():
 
 
 def downgrade():
-    with op.batch_alter_table('ps_contacts') as batch_op:
-        batch_op.drop_column('user_agent')
-    with op.batch_alter_table('ps_endpoints') as batch_op:
-        batch_op.drop_column('message_context')
+    op.drop_column('ps_contacts', 'user_agent')
+    op.drop_column('ps_endpoints', 'message_context')
index 7f2c57978554face1cdbb35901a9aabc5f7fc223..0becc1e263b2abd833d0120079aeb4a6e0e2b346 100644 (file)
@@ -22,5 +22,4 @@ def upgrade():
     op.add_column('ps_transports', sa.Column('allow_reload', yesno_values))
 
 def downgrade():
-    with op.batch_alter_table('ps_transports') as batch_op:
-        batch_op.drop_column('allow_reload')
+    op.drop_column('ps_transports', 'allow_reload')
index bcdfdc52f27faf10d80bb879c4fb7daa885d2949..d104d7a421754f81f1eea7813099674127296dc3 100644 (file)
@@ -14,13 +14,9 @@ from alembic import op
 import sqlalchemy as sa
 
 def upgrade():
-    with op.batch_alter_table('ps_aors') as batch_op:
-        batch_op.alter_column('qualify_timeout', type_=sa.Float)
-    with op.batch_alter_table('ps_contacts') as batch_op:
-        batch_op.alter_column('qualify_timeout', type_=sa.Float)
+    op.alter_column('ps_aors', 'qualify_timeout', type_=sa.Float)
+    op.alter_column('ps_contacts', 'qualify_timeout', type_=sa.Float)
 
 def downgrade():
-    with op.batch_alter_table('ps_aors') as batch_op:
-        batch_op.alter_column('qualify_timeout', type_=sa.Integer)
-    with op.batch_alter_table('ps_contacts') as batch_op:
-        batch_op.alter_column('qualify_timeout', type_=sa.Integer)
+    op.alter_column('ps_aors', 'qualify_timeout', type_=sa.Integer)
+    op.alter_column('ps_contacts', 'qualify_timeout', type_=sa.Integer)
index ffc9cb9c0566aa3a4feed75101d303c6196f2d15..213da92fb270fcf431b3fe01a4d93ea0ad2badbd 100644 (file)
@@ -18,5 +18,4 @@ def upgrade():
     op.add_column('ps_globals', sa.Column('endpoint_identifier_order', sa.String(40)))
 
 def downgrade():
-    with op.batch_alter_table('ps_globals') as batch_op:
-        batch_op.drop_column('endpoint_identifier_order')
+    op.drop_column('ps_globals', 'endpoint_identifier_order')
index ec8a90449fb04fddd2255527a983ea92843a376c..0512ef9368986625e4aa8b0b8ee4f1256272de94 100644 (file)
@@ -18,7 +18,5 @@ def upgrade():
     op.add_column('ps_contacts', sa.Column('qualify_timeout', sa.Integer))
 
 def downgrade():
-    with op.batch_alter_table('ps_aors') as batch_op:
-        batch_op.drop_column('qualify_timeout')
-    with op.batch_alter_table('ps_contacts') as batch_op:
-        batch_op.drop_column('qualify_timeout')
+    op.drop_column('ps_aors', 'qualify_timeout')
+    op.drop_column('ps_contacts', 'qualify_timeout')
index 3ad26509b25354c9713b357ca1791b101e619272..5a4f470aad0a8f435a07aa2894ab5f8bfb6dc4d4 100644 (file)
@@ -19,5 +19,4 @@ def upgrade():
 
 
 def downgrade():
-    with op.batch_alter_table('ps_endpoints') as batch_op:
-        batch_op.drop_column('rtp_keepalive')
+    op.drop_column('ps_endpoints', 'rtp_keepalive')
index d9bbf8977dff7c851ab828760fcf159459e5d449..27b498f30a76ed8a4365c3a5b72d9d3ba9f20d50 100755 (executable)
@@ -19,43 +19,35 @@ YESNO_NAME = 'yesno_values'
 YESNO_VALUES = ['yes', 'no']
 
 def upgrade():
-    with op.batch_alter_table('ps_endpoints') as batch_op:
-        batch_op.alter_column('tos_audio',
-                    type_=sa.String(10))
-        batch_op.alter_column('tos_video',
-                    type_=sa.String(10))
-        batch_op.drop_column('cos_audio')
-        batch_op.drop_column('cos_video')
-        batch_op.add_column(sa.Column('cos_audio', sa.Integer))
-        batch_op.add_column(sa.Column('cos_video', sa.Integer))
-
-    with op.batch_alter_table('ps_transports') as batch_op:
-        batch_op.alter_column('tos',
-                    type_=sa.String(10))
+    op.alter_column('ps_endpoints', 'tos_audio', type_=sa.String(10))
+    op.alter_column('ps_endpoints', 'tos_video', type_=sa.String(10))
+    op.drop_column('ps_endpoints', 'cos_audio')
+    op.drop_column('ps_endpoints', 'cos_video')
+    op.add_column('ps_endpoints', sa.Column('cos_audio', sa.Integer))
+    op.add_column('ps_endpoints', sa.Column('cos_video', sa.Integer))
 
-    # Can't cast YENO_VALUES to Integers, so dropping and adding is required
-        batch_op.drop_column('cos')
+    op.alter_column('ps_transports', 'tos', type_=sa.String(10))
 
-        batch_op.add_column(sa.Column('cos', sa.Integer))
+    # Can't cast YENO_VALUES to Integers, so dropping and adding is required
+    op.drop_column('ps_transports', 'cos')
+    op.add_column('ps_transports', sa.Column('cos', sa.Integer))
 
 def downgrade():
 
     yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=False)
 
     # Can't cast string to YESNO_VALUES, so dropping and adding is required
-    with op.batch_alter_table('ps_endpoints') as batch_op:
-        batch_op.drop_column('tos_audio')
-        batch_op.drop_column('tos_video')
-        batch_op.add_column(sa.Column('tos_audio', yesno_values))
-        batch_op.add_column(sa.Column('tos_video', yesno_values))
-        batch_op.drop_column('cos_audio')
-        batch_op.drop_column('cos_video')
-        batch_op.add_column(sa.Column('cos_audio', yesno_values))
-        batch_op.add_column(sa.Column('cos_video', yesno_values))
-
-    with op.batch_alter_table('ps_transports') as batch_op:
-        batch_op.drop_column('tos')
-        batch_op.add_column(sa.Column('tos', yesno_values))
+    op.drop_column('ps_endpoints', 'tos_audio')
+    op.drop_column('ps_endpoints', 'tos_video')
+    op.add_column('ps_endpoints', sa.Column('tos_audio', yesno_values))
+    op.add_column('ps_endpoints', sa.Column('tos_video', yesno_values))
+    op.drop_column('ps_endpoints', 'cos_audio')
+    op.drop_column('ps_endpoints', 'cos_video')
+    op.add_column('ps_endpoints', sa.Column('cos_audio', yesno_values))
+    op.add_column('ps_endpoints', sa.Column('cos_video', yesno_values))
+
+    op.drop_column('ps_transports', 'tos')
+    op.add_column('ps_transports', sa.Column('tos', yesno_values))
     # Can't cast integers to YESNO_VALUES, so dropping and adding is required
-        batch_op.drop_column('cos')
-        batch_op.add_column(sa.Column('cos', yesno_values))
+    op.drop_column('ps_transports', 'cos')
+    op.add_column('ps_transports', sa.Column('cos', yesno_values))
index 632f4c4eb14082f4d5564626639d5c21b8e7de42..01d4985fe5e9e51f43c86627de137d84636deaa5 100755 (executable)
@@ -36,28 +36,19 @@ def upgrade():
     context = op.get_context()
     # Was unable to find a way to use op.alter_column() to add the unique
     # index property.
-    if context.bind.dialect.name == 'sqlite':
-        with op.batch_alter_table('queue_members') as batch_op:
-            batch_op.create_primary_key('queue_members_pj', columns='uniqueid')
-    else:
-        op.drop_column('queue_members', 'uniqueid')
-        op.add_column(
-                      'queue_members',
-                      sa.Column(
-                                name='uniqueid', type_=sa.Integer, nullable=False,
-                                unique=True))
+    op.drop_column('queue_members', 'uniqueid')
+    op.add_column('queue_members', sa.Column(name='uniqueid', type_=sa.Integer,
+                                             nullable=False, unique=True))
     # The postgres backend does not like the autoincrement needed for
     # mysql here.  It is just the backend that is giving a warning and
     # not the database itself.
-        op.alter_column(
-                        table_name='queue_members', column_name='uniqueid',
-                        existing_type=sa.Integer, existing_nullable=False,
-                        autoincrement=True)
+    op.alter_column(table_name='queue_members', column_name='uniqueid',
+                    existing_type=sa.Integer, existing_nullable=False,
+                    autoincrement=True)
 
 
 def downgrade():
     # Was unable to find a way to use op.alter_column() to remove the
     # unique index property.
-    with op.batch_alter_table('queue_members') as batch_op:
-        batch_op.drop_column('uniqueid')
-        batch_op.add_column(sa.Column(name='uniqueid', type_=sa.String(80), nullable=False))
+    op.drop_column('queue_members', 'uniqueid')
+    op.add_column('queue_members', sa.Column(name='uniqueid', type_=sa.String(80), nullable=False))
index 8d0f68f03d9afb0afda151e7c78a19f0015b5236..c2dacda2c682ce7e4f4bbeae42e08e481a23e96a 100644 (file)
@@ -28,6 +28,5 @@ def upgrade():
     op.add_column('ps_endpoints', sa.Column('media_use_received_transport', yesno_values))
 
 def downgrade():
-    with op.batch_alter_table('ps_endpoints') as batch_op:
-        batch_op.drop_column('force_avp')
-        batch_op.drop_column('media_use_received_transport')
+    op.drop_column('ps_endpoints', 'force_avp')
+    op.drop_column('ps_endpoints', 'media_use_received_transport')
index 2c61f2b9dc8a16605105b1d8b482af8c253090ed..efa0196ac58d3a10d9d2fcde0797bad2876eca76 100644 (file)
@@ -17,5 +17,4 @@ def upgrade():
     op.add_column('ps_globals', sa.Column('contact_expiration_check_interval', sa.Integer))
 
 def downgrade():
-    with op.batch_alter_table('ps_globals') as batch_op:
-        batch_op.drop_column('contact_expiration_check_interval')
+    op.drop_column('ps_globals', 'contact_expiration_check_interval')
index ace5444231d947b9c2a806fc50c9c1e01fa2a27e..28ebc8b1773f606aa2fb5492aac52ace211c9523 100644 (file)
@@ -19,13 +19,11 @@ YESNO_VALUES = ['yes', 'no']
 
 def upgrade():
     yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=False)
-    with op.batch_alter_table('ps_transports') as batch_op:
-        batch_op.alter_column('verifiy_server', type_=yesno_values,
+    op.alter_column('ps_transports', 'verifiy_server', type_=yesno_values,
                     new_column_name='verify_server')
 
 
 def downgrade():
     yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=False)
-    with op.batch_alter_table('ps_transports') as batch_op:
-        batch_op.alter_column('verify_server', type_=yesno_values,
+    op.alter_column('ps_transports', 'verify_server', type_=yesno_values,
                     new_column_name='verifiy_server')
index dc06d84ef1e77d1c1ace352d5e04acd9f16da0d6..0ffd7848da25541c30d19695e93c435d2ef423ef 100644 (file)
@@ -17,5 +17,4 @@ def upgrade():
     op.add_column('ps_globals', sa.Column('max_initial_qualify_time', sa.Integer))
 
 def downgrade():
-    with op.batch_alter_table('ps_globals') as batch_op:
-        batch_op.drop_column('max_initial_qualify_time')
+    op.drop_column('ps_globals', 'max_initial_qualify_time')
index b4502eb3d13a0e95766ccbddb38fae3d6d763cd0..8aa16f1552eb3f121d4e1783368933f2700982a6 100644 (file)
@@ -29,8 +29,6 @@ def upgrade():
     op.add_column('ps_registrations', sa.Column('endpoint', sa.String(40)))
 
 def downgrade():
-    with op.batch_alter_table('ps_systems') as batch_op:
-        batch_op.drop_column('disable_tcp_switch')
-    with op.batch_alter_table('ps_registrations') as batch_op:
-        batch_op.drop_column('line')
-        batch_op.drop_column('endpoint')
+    op.drop_column('ps_systems', 'disable_tcp_switch')
+    op.drop_column('ps_registrations', 'line')
+    op.drop_column('ps_registrations', 'endpoint')
index f25c2987e6f34aa757d2844db2390f20979e318b..9c00c012ef7b3636cb66790b51893ade219740cb 100644 (file)
@@ -15,28 +15,22 @@ import sqlalchemy as sa
 
 
 def upgrade():
-    with op.batch_alter_table('ps_globals') as batch_op:
-        batch_op.alter_column('user_agent', type_=sa.String(255))
+    op.alter_column('ps_globals', 'user_agent', type_=sa.String(255))
 
-    with op.batch_alter_table('ps_contacts') as batch_op:
-        batch_op.alter_column('id', type_=sa.String(255))
-        batch_op.alter_column('uri', type_=sa.String(255))
-        batch_op.alter_column('user_agent', type_=sa.String(255))
+    op.alter_column('ps_contacts', 'id', type_=sa.String(255))
+    op.alter_column('ps_contacts', 'uri', type_=sa.String(255))
+    op.alter_column('ps_contacts', 'user_agent', type_=sa.String(255))
 
-    with op.batch_alter_table('ps_registrations') as batch_op:
-        batch_op.alter_column('client_uri', type_=sa.String(255))
-        batch_op.alter_column('server_uri', type_=sa.String(255))
+    op.alter_column('ps_registrations', 'client_uri', type_=sa.String(255))
+    op.alter_column('ps_registrations', 'server_uri', type_=sa.String(255))
 
 
 def downgrade():
-    with op.batch_alter_table('ps_globals') as batch_op:
-        batch_op.alter_column('user_agent', type_=sa.String(40))
+    op.alter_column('ps_globals', 'user_agent', type_=sa.String(40))
 
-    with op.batch_alter_table('ps_contacts') as batch_op:
-        batch_op.alter_column('id', type_=sa.String(40))
-        batch_op.alter_column('uri', type_=sa.String(40))
-        batch_op.alter_column('user_agent', type_=sa.String(40))
+    op.alter_column('ps_contacts', 'id', type_=sa.String(40))
+    op.alter_column('ps_contacts', 'uri', type_=sa.String(40))
+    op.alter_column('ps_contacts', 'user_agent', type_=sa.String(40))
 
-    with op.batch_alter_table('ps_registrations') as batch_op:
-        batch_op.alter_column('client_uri', type_=sa.String(40))
-        batch_op.alter_column('server_uri', type_=sa.String(40))
+    op.alter_column('ps_registrations', 'client_uri', type_=sa.String(40))
+    op.alter_column('ps_registrations', 'server_uri', type_=sa.String(40))
index 5e50df2703963413d60d782bda0c260ff3459340..2d96b37f70d60644a8ece5d7ad606cda04b4af1e 100644 (file)
@@ -28,5 +28,4 @@ def upgrade():
 
 
 def downgrade():
-    with op.batch_alter_table('ps_endpoints') as batch_op:
-        batch_op.drop_column('media_encryption_optimistic')
+    op.drop_column('ps_endpoints', 'media_encryption_optimistic')