<p>Jenkins2 <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/6424">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Jenkins2: Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">alembic: Add support for MS-SQL<br><br>MS-SQL has no native Enum-type support and therefore<br>needs to work with constraints.<br>Since these constraints need unique names the suggested approach<br>referenced in the following alembic documentation has been applied:<br>http://bit.ly/2x9r8pb<br><br>ASTERISK-27255 #close<br><br>Change-Id: I8b579750dae0c549f1103ee50172644afb9b2f95<br>---<br>M contrib/ast-db-manage/config/versions/15b1430ad6f1_add_moh_passthrough_option_to_pjsip.py<br>M contrib/ast-db-manage/config/versions/15db7b91a97a_add_rtcp_mux.py<br>M contrib/ast-db-manage/config/versions/23530d604b96_add_rpid_immediate.py<br>M contrib/ast-db-manage/config/versions/26d7f3bf0fa5_add_bind_rtp_to_media_address_to_pjsip.py<br>M contrib/ast-db-manage/config/versions/28ab27a7826d_add_srv_lookups_to_identify.py<br>M contrib/ast-db-manage/config/versions/28b8e71e541f_add_g726_non_standard.py<br>M contrib/ast-db-manage/config/versions/2fc7930b41b3_add_pjsip_endpoint_options_for_12_1.py<br>M contrib/ast-db-manage/config/versions/371a3bf4143e_add_user_eq_phone_option_to_pjsip.py<br>M contrib/ast-db-manage/config/versions/3772f8f828da_update_identify_by.py<br>M contrib/ast-db-manage/config/versions/3bcc0b5bc2c9_add_allow_reload_to_ps_transports.py<br>M contrib/ast-db-manage/config/versions/4468b4a91372_add_pjsip_asymmetric_rtp_codec.py<br>M contrib/ast-db-manage/config/versions/4c573e7135bd_fix_tos_field_types.py<br>M contrib/ast-db-manage/config/versions/5139253c0423_make_q_member_uniqueid_autoinc.py<br>M contrib/ast-db-manage/config/versions/51f8cb66540e_add_further_dtls_options.py<br>M contrib/ast-db-manage/config/versions/5950038a6ead_fix_pjsip_verifiy_typo.py<br>M contrib/ast-db-manage/config/versions/837aa67461fb_ps_contacts_add_authenticate_qualify.py<br>M contrib/ast-db-manage/config/versions/86bb1efa278d_add_ps_endpoints_refer_blind_progress.py<br>M contrib/ast-db-manage/config/versions/8d478ab86e29_pjsip_add_disable_multi_domain.py<br>M contrib/ast-db-manage/config/versions/8fce4c573e15_add_pjsip_allow_overlap.py<br>M contrib/ast-db-manage/config/versions/945b1098bdd_add_media_encryption_optimistic_to_pjsip.py<br>M contrib/ast-db-manage/config/versions/a6ef36f1309_ps_globals_add_ignore_uri_user_options.py<br>M contrib/ast-db-manage/config/versions/b83645976fdd_add_dtls_fingerprint_to_ps_endpoints.py<br>M contrib/ast-db-manage/config/versions/c7a44a5a0851_pjsip_add_global_mwi_options.py<br>M contrib/ast-db-manage/config/versions/d7983954dd96_add_ps_endpoints_notify_early_inuse_.py<br>M contrib/ast-db-manage/config/versions/dbc44d5a908_add_missing_columns_to_sys_and_reg.py<br>M contrib/ast-db-manage/config/versions/e96a0b8071c_increase_pjsip_column_size.py<br>M contrib/ast-db-manage/config/versions/ef7efc2d3964_ps_contacts_add_endpoint_and_modify_.py<br>M contrib/ast-db-manage/config/versions/f3d1c5d38b56_add_prune_on_boot.py<br>M contrib/ast-db-manage/config/versions/f638dbe2eb23_symmetric_transport.py<br>M contrib/ast-db-manage/env.py<br>30 files changed, 104 insertions(+), 12 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/contrib/ast-db-manage/config/versions/15b1430ad6f1_add_moh_passthrough_option_to_pjsip.py b/contrib/ast-db-manage/config/versions/15b1430ad6f1_add_moh_passthrough_option_to_pjsip.py<br>index 725238c..2456dac 100644<br>--- a/contrib/ast-db-manage/config/versions/15b1430ad6f1_add_moh_passthrough_option_to_pjsip.py<br>+++ b/contrib/ast-db-manage/config/versions/15b1430ad6f1_add_moh_passthrough_option_to_pjsip.py<br>@@ -27,5 +27,7 @@<br>     op.add_column('ps_endpoints', sa.Column('moh_passthrough', yesno_values))<br> <br> def downgrade():<br>+    if op.get_context().bind.dialect.name == 'mssql':<br>+        op.drop_constraint('ck_ps_endpoints_moh_passthrough_yesno_values','ps_endpoints')<br>     with op.batch_alter_table('ps_endpoints') as batch_op:<br>         batch_op.drop_column('moh_passthrough')<br>diff --git a/contrib/ast-db-manage/config/versions/15db7b91a97a_add_rtcp_mux.py b/contrib/ast-db-manage/config/versions/15db7b91a97a_add_rtcp_mux.py<br>index 8b0214a..de9e10a 100644<br>--- a/contrib/ast-db-manage/config/versions/15db7b91a97a_add_rtcp_mux.py<br>+++ b/contrib/ast-db-manage/config/versions/15db7b91a97a_add_rtcp_mux.py<br>@@ -28,4 +28,6 @@<br> <br> <br> def downgrade():<br>+    if op.get_context().bind.dialect.name == 'mssql':<br>+        op.drop_constraint('ck_ps_endpoints_rtcp_mux_yesno_values','ps_endpoints')<br>     op.drop_column('ps_endpoints', 'rtcp_mux')<br>diff --git a/contrib/ast-db-manage/config/versions/23530d604b96_add_rpid_immediate.py b/contrib/ast-db-manage/config/versions/23530d604b96_add_rpid_immediate.py<br>index dc0c01c..b3ffaee 100644<br>--- a/contrib/ast-db-manage/config/versions/23530d604b96_add_rpid_immediate.py<br>+++ b/contrib/ast-db-manage/config/versions/23530d604b96_add_rpid_immediate.py<br>@@ -45,4 +45,6 @@<br>     op.add_column('ps_endpoints', sa.Column('rpid_immediate', yesno_values))<br> <br> def downgrade():<br>+    if op.get_context().bind.dialect.name == 'mssql':<br>+        op.drop_constraint('ck_ps_endpoints_rpid_immediate_yesno_values','ps_endpoints')<br>     op.drop_column('ps_endpoints', 'rpid_immediate')<br>diff --git a/contrib/ast-db-manage/config/versions/26d7f3bf0fa5_add_bind_rtp_to_media_address_to_pjsip.py b/contrib/ast-db-manage/config/versions/26d7f3bf0fa5_add_bind_rtp_to_media_address_to_pjsip.py<br>index e7c11da..ce2ac1e 100644<br>--- a/contrib/ast-db-manage/config/versions/26d7f3bf0fa5_add_bind_rtp_to_media_address_to_pjsip.py<br>+++ b/contrib/ast-db-manage/config/versions/26d7f3bf0fa5_add_bind_rtp_to_media_address_to_pjsip.py<br>@@ -28,4 +28,6 @@<br> <br> <br> def downgrade():<br>+    if op.get_context().bind.dialect.name == 'mssql':<br>+        op.drop_constraint('ck_ps_endpoints_bind_rtp_to_media_address_yesno_values','ps_endpoints')<br>     op.drop_column('ps_endpoints', 'bind_rtp_to_media_address')<br>diff --git a/contrib/ast-db-manage/config/versions/28ab27a7826d_add_srv_lookups_to_identify.py b/contrib/ast-db-manage/config/versions/28ab27a7826d_add_srv_lookups_to_identify.py<br>index 8831e20..9325da3 100644<br>--- a/contrib/ast-db-manage/config/versions/28ab27a7826d_add_srv_lookups_to_identify.py<br>+++ b/contrib/ast-db-manage/config/versions/28ab27a7826d_add_srv_lookups_to_identify.py<br>@@ -28,4 +28,6 @@<br> <br> <br> def downgrade():<br>+    if op.get_context().bind.dialect.name == 'mssql':<br>+        op.drop_constraint('ck_ps_endpoint_id_ips_srv_lookups_yesno_values','ps_endpoint_id_ips')<br>     op.drop_column('ps_endpoint_id_ips', 'srv_lookups')<br>diff --git a/contrib/ast-db-manage/config/versions/28b8e71e541f_add_g726_non_standard.py b/contrib/ast-db-manage/config/versions/28b8e71e541f_add_g726_non_standard.py<br>index ad36bd9..08e2e3f 100644<br>--- a/contrib/ast-db-manage/config/versions/28b8e71e541f_add_g726_non_standard.py<br>+++ b/contrib/ast-db-manage/config/versions/28b8e71e541f_add_g726_non_standard.py<br>@@ -27,4 +27,6 @@<br> <br> <br> def downgrade():<br>+    if op.get_context().bind.dialect.name == 'mssql':<br>+        op.drop_constraint('ck_ps_endpoints_g726_non_standard_yesno_values','ps_endpoints')<br>     op.drop_column('ps_endpoints', 'g726_non_standard')<br>diff --git a/contrib/ast-db-manage/config/versions/2fc7930b41b3_add_pjsip_endpoint_options_for_12_1.py b/contrib/ast-db-manage/config/versions/2fc7930b41b3_add_pjsip_endpoint_options_for_12_1.py<br>index d39ddb4..3ca16fe 100644<br>--- a/contrib/ast-db-manage/config/versions/2fc7930b41b3_add_pjsip_endpoint_options_for_12_1.py<br>+++ b/contrib/ast-db-manage/config/versions/2fc7930b41b3_add_pjsip_endpoint_options_for_12_1.py<br>@@ -142,6 +142,8 @@<br> def downgrade():<br>     ########################## drop columns ##########################<br> <br>+    if op.get_context().bind.dialect.name == 'mssql':<br>+        op.drop_constraint('ck_ps_aors_support_path_yesno_values', 'ps_aors')<br>     op.drop_column('ps_aors', 'support_path')<br>     op.drop_column('ps_aors', 'outbound_proxy')<br>     op.drop_column('ps_aors', 'maximum_expiration')<br>@@ -153,6 +155,8 @@<br>         new_column_name='mwi_fromuser', existing_type=sa.String(40))<br> <br>     op.drop_column('ps_endpoints', 'set_var')<br>+    if op.get_context().bind.dialect.name == 'mssql':<br>+        op.drop_constraint('ck_ps_endpoints_redirect_method_pjsip_redirect_method_values', 'ps_endpoints')<br>     op.drop_column('ps_endpoints', 'redirect_method')<br>     op.drop_column('ps_endpoints', 'media_address')<br> <br>diff --git a/contrib/ast-db-manage/config/versions/371a3bf4143e_add_user_eq_phone_option_to_pjsip.py b/contrib/ast-db-manage/config/versions/371a3bf4143e_add_user_eq_phone_option_to_pjsip.py<br>index 145d6be..29558ce 100644<br>--- a/contrib/ast-db-manage/config/versions/371a3bf4143e_add_user_eq_phone_option_to_pjsip.py<br>+++ b/contrib/ast-db-manage/config/versions/371a3bf4143e_add_user_eq_phone_option_to_pjsip.py<br>@@ -27,4 +27,6 @@<br>     op.add_column('ps_endpoints', sa.Column('user_eq_phone', yesno_values))<br> <br> def downgrade():<br>+    if op.get_context().bind.dialect.name == 'mssql':<br>+        op.drop_constraint('ck_ps_endpoints_user_eq_phone_yesno_values','ps_endpoints')<br>     op.drop_column('ps_endpoints', 'user_eq_phone')<br>diff --git a/contrib/ast-db-manage/config/versions/3772f8f828da_update_identify_by.py b/contrib/ast-db-manage/config/versions/3772f8f828da_update_identify_by.py<br>index 92695b0..3c80f48 100644<br>--- a/contrib/ast-db-manage/config/versions/3772f8f828da_update_identify_by.py<br>+++ b/contrib/ast-db-manage/config/versions/3772f8f828da_update_identify_by.py<br>@@ -16,6 +16,8 @@<br> <br> def enum_update(table_name, column_name, enum_name, enum_values):<br>     if op.get_context().bind.dialect.name != 'postgresql':<br>+        if op.get_context().bind.dialect.name == 'mssql':<br>+            op.drop_constraint('ck_ps_endpoints_identify_by_pjsip_identify_by_values', 'ps_endpoints')<br>         op.alter_column(table_name, column_name,<br>                         type_=sa.Enum(*enum_values, name=enum_name))<br>         return<br>diff --git a/contrib/ast-db-manage/config/versions/3bcc0b5bc2c9_add_allow_reload_to_ps_transports.py b/contrib/ast-db-manage/config/versions/3bcc0b5bc2c9_add_allow_reload_to_ps_transports.py<br>index 0becc1e..093a5d4 100644<br>--- a/contrib/ast-db-manage/config/versions/3bcc0b5bc2c9_add_allow_reload_to_ps_transports.py<br>+++ b/contrib/ast-db-manage/config/versions/3bcc0b5bc2c9_add_allow_reload_to_ps_transports.py<br>@@ -22,4 +22,6 @@<br>     op.add_column('ps_transports', sa.Column('allow_reload', yesno_values))<br> <br> def downgrade():<br>+    if op.get_context().bind.dialect.name == 'mssql':<br>+        op.drop_constraint('ck_ps_transports_allow_reload_yesno_values','ps_transports')<br>     op.drop_column('ps_transports', 'allow_reload')<br>diff --git a/contrib/ast-db-manage/config/versions/4468b4a91372_add_pjsip_asymmetric_rtp_codec.py b/contrib/ast-db-manage/config/versions/4468b4a91372_add_pjsip_asymmetric_rtp_codec.py<br>index c121495..1a8ede6 100644<br>--- a/contrib/ast-db-manage/config/versions/4468b4a91372_add_pjsip_asymmetric_rtp_codec.py<br>+++ b/contrib/ast-db-manage/config/versions/4468b4a91372_add_pjsip_asymmetric_rtp_codec.py<br>@@ -28,4 +28,6 @@<br> <br> <br> def downgrade():<br>+    if op.get_context().bind.dialect.name == 'mssql':<br>+        op.drop_constraint('ck_ps_endpoints_asymmetric_rtp_codec_yesno_values','ps_endpoints')<br>     op.drop_column('ps_endpoints', 'asymmetric_rtp_codec')<br>diff --git a/contrib/ast-db-manage/config/versions/4c573e7135bd_fix_tos_field_types.py b/contrib/ast-db-manage/config/versions/4c573e7135bd_fix_tos_field_types.py<br>index 27b498f..f99e2ea 100644<br>--- a/contrib/ast-db-manage/config/versions/4c573e7135bd_fix_tos_field_types.py<br>+++ b/contrib/ast-db-manage/config/versions/4c573e7135bd_fix_tos_field_types.py<br>@@ -29,7 +29,7 @@<br>     op.alter_column('ps_transports', 'tos', type_=sa.String(10))<br> <br>     # Can't cast YENO_VALUES to Integers, so dropping and adding is required<br>-    op.drop_column('ps_transports', 'cos')<br>+    op.drop_column('ps_transports', 'cos', schema=None, mssql_drop_check=True)<br>     op.add_column('ps_transports', sa.Column('cos', sa.Integer))<br> <br> def downgrade():<br>@@ -46,6 +46,8 @@<br>     op.add_column('ps_endpoints', sa.Column('cos_audio', yesno_values))<br>     op.add_column('ps_endpoints', sa.Column('cos_video', yesno_values))<br> <br>+    if op.get_context().bind.dialect.name == 'mssql':<br>+        op.drop_constraint('ck_ps_transports_tos_yesno_values', 'ps_transports')<br>     op.drop_column('ps_transports', 'tos')<br>     op.add_column('ps_transports', sa.Column('tos', yesno_values))<br>     # Can't cast integers to YESNO_VALUES, so dropping and adding is required<br>diff --git a/contrib/ast-db-manage/config/versions/5139253c0423_make_q_member_uniqueid_autoinc.py b/contrib/ast-db-manage/config/versions/5139253c0423_make_q_member_uniqueid_autoinc.py<br>index 01d4985..3b329b5 100644<br>--- a/contrib/ast-db-manage/config/versions/5139253c0423_make_q_member_uniqueid_autoinc.py<br>+++ b/contrib/ast-db-manage/config/versions/5139253c0423_make_q_member_uniqueid_autoinc.py<br>@@ -39,7 +39,7 @@<br>     op.drop_column('queue_members', 'uniqueid')<br>     op.add_column('queue_members', sa.Column(name='uniqueid', type_=sa.Integer,<br>                                              nullable=False, unique=True))<br>-    # The postgres backend does not like the autoincrement needed for<br>+    # The postgres and mssql backends do not like the autoincrement needed for<br>     # mysql here.  It is just the backend that is giving a warning and<br>     # not the database itself.<br>     op.alter_column(table_name='queue_members', column_name='uniqueid',<br>@@ -50,5 +50,7 @@<br> def downgrade():<br>     # Was unable to find a way to use op.alter_column() to remove the<br>     # unique index property.<br>+    if op.get_context().bind.dialect.name == 'mssql':<br>+        op.drop_constraint('uq_queue_members_uniqueid', 'queue_members')<br>     op.drop_column('queue_members', 'uniqueid')<br>     op.add_column('queue_members', sa.Column(name='uniqueid', type_=sa.String(80), nullable=False))<br>diff --git a/contrib/ast-db-manage/config/versions/51f8cb66540e_add_further_dtls_options.py b/contrib/ast-db-manage/config/versions/51f8cb66540e_add_further_dtls_options.py<br>index c2dacda..2eea713 100644<br>--- a/contrib/ast-db-manage/config/versions/51f8cb66540e_add_further_dtls_options.py<br>+++ b/contrib/ast-db-manage/config/versions/51f8cb66540e_add_further_dtls_options.py<br>@@ -28,5 +28,8 @@<br>     op.add_column('ps_endpoints', sa.Column('media_use_received_transport', yesno_values))<br> <br> def downgrade():<br>+    if op.get_context().bind.dialect.name == 'mssql':<br>+        op.drop_constraint('ck_ps_endpoints_force_avp_yesno_values', 'ps_endpoints')<br>+        op.drop_constraint('ck_ps_endpoints_media_use_received_transport_yesno_values', 'ps_endpoints')<br>     op.drop_column('ps_endpoints', 'force_avp')<br>     op.drop_column('ps_endpoints', 'media_use_received_transport')<br>diff --git a/contrib/ast-db-manage/config/versions/5950038a6ead_fix_pjsip_verifiy_typo.py b/contrib/ast-db-manage/config/versions/5950038a6ead_fix_pjsip_verifiy_typo.py<br>index 28ebc8b..a1154a3 100644<br>--- a/contrib/ast-db-manage/config/versions/5950038a6ead_fix_pjsip_verifiy_typo.py<br>+++ b/contrib/ast-db-manage/config/versions/5950038a6ead_fix_pjsip_verifiy_typo.py<br>@@ -11,19 +11,32 @@<br> down_revision = 'd39508cb8d8'<br> <br> from alembic import op<br>+import sqlalchemy as sa<br> from sqlalchemy.dialects.postgresql import ENUM<br> <br> YESNO_NAME = 'yesno_values'<br> YESNO_VALUES = ['yes', 'no']<br> <br>-<br> def upgrade():<br>     yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=False)<br>-    op.alter_column('ps_transports', 'verifiy_server', type_=yesno_values,<br>-                    new_column_name='verify_server')<br>+<br>+    if op.get_context().bind.dialect.name != 'mssql':<br>+        op.alter_column('ps_transports', 'verifiy_server', type_=yesno_values,<br>+                        new_column_name='verify_server')<br>+    else:<br>+        op.alter_column('ps_transports', 'verifiy_server', existing_type=yesno_values, type_=sa.String(3),<br>+                        new_column_name='verify_server')<br>+        yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=True)<br>+        op.alter_column('ps_transports', 'verify_server', existing_type=sa.String(3), type_=yesno_values)<br> <br> <br> def downgrade():<br>     yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=False)<br>-    op.alter_column('ps_transports', 'verify_server', type_=yesno_values,<br>-                    new_column_name='verifiy_server')<br>+    if op.get_context().bind.dialect.name != 'mssql':<br>+        op.alter_column('ps_transports', 'verify_server', type_=yesno_values,<br>+                        new_column_name='verifiy_server')<br>+    else:<br>+        op.alter_column('ps_transports', 'verify_server', existing_type=yesno_values, type_=sa.String(3),<br>+                        new_column_name='verifiy_server')<br>+        yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=True)<br>+        op.alter_column('ps_transports', 'verifiy_server', existing_type=sa.String(3), type_=yesno_values)<br>diff --git a/contrib/ast-db-manage/config/versions/837aa67461fb_ps_contacts_add_authenticate_qualify.py b/contrib/ast-db-manage/config/versions/837aa67461fb_ps_contacts_add_authenticate_qualify.py<br>index 76faf39..033a999 100644<br>--- a/contrib/ast-db-manage/config/versions/837aa67461fb_ps_contacts_add_authenticate_qualify.py<br>+++ b/contrib/ast-db-manage/config/versions/837aa67461fb_ps_contacts_add_authenticate_qualify.py<br>@@ -28,5 +28,7 @@<br> <br> <br> def downgrade():<br>+    if op.get_context().bind.dialect.name == 'mssql':<br>+        op.drop_constraint('ck_ps_contacts_authenticate_qualify_yesno_values','ps_contacts')<br>     op.drop_column('ps_contacts', 'authenticate_qualify')<br> <br>diff --git a/contrib/ast-db-manage/config/versions/86bb1efa278d_add_ps_endpoints_refer_blind_progress.py b/contrib/ast-db-manage/config/versions/86bb1efa278d_add_ps_endpoints_refer_blind_progress.py<br>index 9b0f6d4..a46ed0c 100644<br>--- a/contrib/ast-db-manage/config/versions/86bb1efa278d_add_ps_endpoints_refer_blind_progress.py<br>+++ b/contrib/ast-db-manage/config/versions/86bb1efa278d_add_ps_endpoints_refer_blind_progress.py<br>@@ -27,4 +27,6 @@<br>     op.add_column('ps_endpoints', sa.Column('refer_blind_progress', yesno_values))<br> <br> def downgrade():<br>+    if op.get_context().bind.dialect.name == 'mssql':<br>+        op.drop_constraint('ck_ps_endpoints_refer_blind_progress_yesno_values','ps_endpoints')<br>     op.drop_column('ps_endpoints', 'refer_blind_progress')<br>diff --git a/contrib/ast-db-manage/config/versions/8d478ab86e29_pjsip_add_disable_multi_domain.py b/contrib/ast-db-manage/config/versions/8d478ab86e29_pjsip_add_disable_multi_domain.py<br>index a782685..a8d7b48 100644<br>--- a/contrib/ast-db-manage/config/versions/8d478ab86e29_pjsip_add_disable_multi_domain.py<br>+++ b/contrib/ast-db-manage/config/versions/8d478ab86e29_pjsip_add_disable_multi_domain.py<br>@@ -28,4 +28,6 @@<br> <br> <br> def downgrade():<br>+    if op.get_context().bind.dialect.name == 'mssql':<br>+        op.drop_constraint('ck_ps_globals_disable_multi_domain_yesno_values','ps_globals')<br>     op.drop_column('ps_globals', 'disable_multi_domain')<br>diff --git a/contrib/ast-db-manage/config/versions/8fce4c573e15_add_pjsip_allow_overlap.py b/contrib/ast-db-manage/config/versions/8fce4c573e15_add_pjsip_allow_overlap.py<br>index 24057ec..539944e 100644<br>--- a/contrib/ast-db-manage/config/versions/8fce4c573e15_add_pjsip_allow_overlap.py<br>+++ b/contrib/ast-db-manage/config/versions/8fce4c573e15_add_pjsip_allow_overlap.py<br>@@ -28,4 +28,6 @@<br> <br> <br> def downgrade():<br>+    if op.get_context().bind.dialect.name == 'mssql':<br>+        op.drop_constraint('ck_ps_endpoints_allow_overlap_yesno_values','ps_endpoints')<br>     op.drop_column('ps_endpoints', 'allow_overlap')<br>diff --git a/contrib/ast-db-manage/config/versions/945b1098bdd_add_media_encryption_optimistic_to_pjsip.py b/contrib/ast-db-manage/config/versions/945b1098bdd_add_media_encryption_optimistic_to_pjsip.py<br>index 7a463f0..61ec272 100644<br>--- a/contrib/ast-db-manage/config/versions/945b1098bdd_add_media_encryption_optimistic_to_pjsip.py<br>+++ b/contrib/ast-db-manage/config/versions/945b1098bdd_add_media_encryption_optimistic_to_pjsip.py<br>@@ -28,4 +28,6 @@<br> <br> <br> def downgrade():<br>+    if op.get_context().bind.dialect.name == 'mssql':<br>+        op.drop_constraint('ck_ps_endpoints_media_encryption_optimistic_yesno_values','ps_endpoints')<br>     op.drop_column('ps_endpoints', 'media_encryption_optimistic')<br>diff --git a/contrib/ast-db-manage/config/versions/a6ef36f1309_ps_globals_add_ignore_uri_user_options.py b/contrib/ast-db-manage/config/versions/a6ef36f1309_ps_globals_add_ignore_uri_user_options.py<br>index 2ce40a0..4daa422 100644<br>--- a/contrib/ast-db-manage/config/versions/a6ef36f1309_ps_globals_add_ignore_uri_user_options.py<br>+++ b/contrib/ast-db-manage/config/versions/a6ef36f1309_ps_globals_add_ignore_uri_user_options.py<br>@@ -28,5 +28,7 @@<br> <br> <br> def downgrade():<br>+    if op.get_context().bind.dialect.name == 'mssql':<br>+        op.drop_constraint('ck_ps_globals_ignore_uri_user_options_yesno_values','ps_globals')<br>     op.drop_column('ps_globals', 'ignore_uri_user_options')<br> <br>diff --git a/contrib/ast-db-manage/config/versions/b83645976fdd_add_dtls_fingerprint_to_ps_endpoints.py b/contrib/ast-db-manage/config/versions/b83645976fdd_add_dtls_fingerprint_to_ps_endpoints.py<br>index 3d4f74d..42b522c 100644<br>--- a/contrib/ast-db-manage/config/versions/b83645976fdd_add_dtls_fingerprint_to_ps_endpoints.py<br>+++ b/contrib/ast-db-manage/config/versions/b83645976fdd_add_dtls_fingerprint_to_ps_endpoints.py<br>@@ -31,6 +31,8 @@<br> def downgrade():<br>     context = op.get_context()<br> <br>+    if context.bind.dialect.name == 'mssql':<br>+        op.drop_constraint('ck_ps_endpoints_dtls_fingerprint_sha_hash_values', 'ps_endpoints')<br>     op.drop_column('ps_endpoints', 'dtls_fingerprint')<br> <br>     if context.bind.dialect.name == 'postgresql':<br>diff --git a/contrib/ast-db-manage/config/versions/c7a44a5a0851_pjsip_add_global_mwi_options.py b/contrib/ast-db-manage/config/versions/c7a44a5a0851_pjsip_add_global_mwi_options.py<br>index d3efa22..c762fc4 100644<br>--- a/contrib/ast-db-manage/config/versions/c7a44a5a0851_pjsip_add_global_mwi_options.py<br>+++ b/contrib/ast-db-manage/config/versions/c7a44a5a0851_pjsip_add_global_mwi_options.py<br>@@ -32,4 +32,6 @@<br> def downgrade():<br>     op.drop_column('ps_globals', 'mwi_tps_queue_high')<br>     op.drop_column('ps_globals', 'mwi_tps_queue_low')<br>+    if op.get_context().bind.dialect.name == 'mssql':<br>+        op.drop_constraint('ck_ps_globals_mwi_disable_initial_unsolicited_yesno_values','ps_globals')<br>     op.drop_column('ps_globals', 'mwi_disable_initial_unsolicited')<br>diff --git a/contrib/ast-db-manage/config/versions/d7983954dd96_add_ps_endpoints_notify_early_inuse_.py b/contrib/ast-db-manage/config/versions/d7983954dd96_add_ps_endpoints_notify_early_inuse_.py<br>index e1dcdd1..a5419a1 100644<br>--- a/contrib/ast-db-manage/config/versions/d7983954dd96_add_ps_endpoints_notify_early_inuse_.py<br>+++ b/contrib/ast-db-manage/config/versions/d7983954dd96_add_ps_endpoints_notify_early_inuse_.py<br>@@ -27,4 +27,6 @@<br>     op.add_column('ps_endpoints', sa.Column('notify_early_inuse_ringing', yesno_values))<br> <br> def downgrade():<br>+    if op.get_context().bind.dialect.name == 'mssql':<br>+        op.drop_constraint('ck_ps_endpoints_notify_early_inuse_ringing_yesno_values', 'ps_endpoints')<br>     op.drop_column('ps_endpoints', 'notify_early_inuse_ringing')<br>diff --git a/contrib/ast-db-manage/config/versions/dbc44d5a908_add_missing_columns_to_sys_and_reg.py b/contrib/ast-db-manage/config/versions/dbc44d5a908_add_missing_columns_to_sys_and_reg.py<br>index 8aa16f1..9acd4a0 100644<br>--- a/contrib/ast-db-manage/config/versions/dbc44d5a908_add_missing_columns_to_sys_and_reg.py<br>+++ b/contrib/ast-db-manage/config/versions/dbc44d5a908_add_missing_columns_to_sys_and_reg.py<br>@@ -29,6 +29,9 @@<br>     op.add_column('ps_registrations', sa.Column('endpoint', sa.String(40)))<br> <br> def downgrade():<br>+    if op.get_context().bind.dialect.name == 'mssql':<br>+        op.drop_constraint('ck_ps_systems_disable_tcp_switch_yesno_values','ps_systems')<br>+        op.drop_constraint('ck_ps_registrations_line_yesno_values','ps_registrations')<br>     op.drop_column('ps_systems', 'disable_tcp_switch')<br>     op.drop_column('ps_registrations', 'line')<br>     op.drop_column('ps_registrations', 'endpoint')<br>diff --git a/contrib/ast-db-manage/config/versions/e96a0b8071c_increase_pjsip_column_size.py b/contrib/ast-db-manage/config/versions/e96a0b8071c_increase_pjsip_column_size.py<br>index 9c00c01..da103b1 100644<br>--- a/contrib/ast-db-manage/config/versions/e96a0b8071c_increase_pjsip_column_size.py<br>+++ b/contrib/ast-db-manage/config/versions/e96a0b8071c_increase_pjsip_column_size.py<br>@@ -28,7 +28,13 @@<br> def downgrade():<br>     op.alter_column('ps_globals', 'user_agent', type_=sa.String(40))<br> <br>-    op.alter_column('ps_contacts', 'id', type_=sa.String(40))<br>+    if op.get_context().bind.dialect.name != 'mssql':<br>+        op.alter_column('ps_contacts', 'id', type_=sa.String(40))<br>+    else:<br>+        op.drop_constraint('uq_ps_contacts_id', 'ps_contacts')<br>+        op.drop_index('ps_contacts_id', 'ps_contacts')<br>+        op.alter_column('ps_contacts', 'id', type_=sa.String(40))<br>+        op.create_index('ps_contacts_id', 'ps_contacts', ['id'])<br>     op.alter_column('ps_contacts', 'uri', type_=sa.String(40))<br>     op.alter_column('ps_contacts', 'user_agent', type_=sa.String(40))<br> <br>diff --git a/contrib/ast-db-manage/config/versions/ef7efc2d3964_ps_contacts_add_endpoint_and_modify_.py b/contrib/ast-db-manage/config/versions/ef7efc2d3964_ps_contacts_add_endpoint_and_modify_.py<br>index 43d4028..0ac63c8 100644<br>--- a/contrib/ast-db-manage/config/versions/ef7efc2d3964_ps_contacts_add_endpoint_and_modify_.py<br>+++ b/contrib/ast-db-manage/config/versions/ef7efc2d3964_ps_contacts_add_endpoint_and_modify_.py<br>@@ -27,7 +27,11 @@<br>     op.create_index('ps_contacts_qualifyfreq_exp', 'ps_contacts', ['qualify_frequency', 'expiration_time'])<br>     op.create_index('ps_aors_qualifyfreq_contact', 'ps_aors', ['qualify_frequency', 'contact'])<br> def downgrade():<br>-    op.drop_index('ps_aors_qualifyfreq_contact')<br>-    op.drop_index('ps_contacts_qualifyfreq_exp')<br>+    if op.get_context().bind.dialect.name != 'mssql':<br>+        op.drop_index('ps_aors_qualifyfreq_contact')<br>+        op.drop_index('ps_contacts_qualifyfreq_exp')<br>+    else:<br>+        op.drop_index('ps_aors_qualifyfreq_contact', table_name='ps_aors')<br>+        op.drop_index('ps_contacts_qualifyfreq_exp', table_name='ps_contacts')<br>     op.drop_column('ps_contacts', 'endpoint')<br>     op.alter_column('ps_contacts', 'expiration_time', type_=sa.String(40))<br>diff --git a/contrib/ast-db-manage/config/versions/f3d1c5d38b56_add_prune_on_boot.py b/contrib/ast-db-manage/config/versions/f3d1c5d38b56_add_prune_on_boot.py<br>index 7596646..83baf5b 100644<br>--- a/contrib/ast-db-manage/config/versions/f3d1c5d38b56_add_prune_on_boot.py<br>+++ b/contrib/ast-db-manage/config/versions/f3d1c5d38b56_add_prune_on_boot.py<br>@@ -28,4 +28,6 @@<br> <br> <br> def downgrade():<br>+    if op.get_context().bind.dialect.name == 'mssql':<br>+        op.drop_constraint('ck_ps_contacts_prune_on_boot_yesno_values', 'ps_contacts')<br>     op.drop_column('ps_contacts', 'prune_on_boot')<br>diff --git a/contrib/ast-db-manage/config/versions/f638dbe2eb23_symmetric_transport.py b/contrib/ast-db-manage/config/versions/f638dbe2eb23_symmetric_transport.py<br>index 51b5066..0585aa5 100644<br>--- a/contrib/ast-db-manage/config/versions/f638dbe2eb23_symmetric_transport.py<br>+++ b/contrib/ast-db-manage/config/versions/f638dbe2eb23_symmetric_transport.py<br>@@ -29,4 +29,6 @@<br> <br> def downgrade():<br>     op.drop_column('ps_subscription_persistence', 'contact_uri')<br>+    if op.get_context().bind.dialect.name == 'mssql':<br>+        op.drop_constraint('ck_ps_transports_symmetric_transport_yesno_values','ps_transports')<br>     op.drop_column('ps_transports', 'symmetric_transport')<br>diff --git a/contrib/ast-db-manage/env.py b/contrib/ast-db-manage/env.py<br>index a903451..1864239 100644<br>--- a/contrib/ast-db-manage/env.py<br>+++ b/contrib/ast-db-manage/env.py<br>@@ -2,7 +2,8 @@<br> from alembic import context<br> from alembic.script import ScriptDirectory<br> from alembic.operations import Operations<br>-from sqlalchemy import engine_from_config, pool<br>+from sqlalchemy import engine_from_config, pool, MetaData<br>+from sqlalchemy.ext.declarative import declarative_base<br> from logging.config import fileConfig<br> import logging<br> <br>@@ -17,12 +18,24 @@<br> except:<br>     pass<br> <br>+## below block is needed for mssql<br>+meta = MetaData(naming_convention = {<br>+     "ix": 'ix_%(column_0_label)s',<br>+     "uq": "uq_%(table_name)s_%(column_0_name)s",<br>+     "ck": "ck_%(table_name)s_%(column_0_name)s_%(constraint_name)s",<br>+ "fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s",<br>+     "pk": "pk_%(table_name)s"<br>+})<br>+Base = declarative_base(metadata=meta)<br>+<br> logger = logging.getLogger('alembic.runtime.setup')<br> # add your model's MetaData object here<br> # for 'autogenerate' support<br> # from myapp import mymodel<br> # target_metadata = mymodel.Base.metadata<br> target_metadata = None<br>+#Comment above line and uncomment below line for mssql<br>+#target_metadata = Base.metadata<br> <br> # other values from the config, defined by the needs of env.py,<br> # can be acquired:<br>@@ -42,7 +55,7 @@<br> <br>     """<br>     url = config.get_main_option("sqlalchemy.url")<br>-    context.configure(url=url)<br>+    context.configure(url=url,target_metadata=target_metadata)<br> <br>     with context.begin_transaction():<br>         context.run_migrations()<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/6424">change 6424</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/6424"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 14 </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I8b579750dae0c549f1103ee50172644afb9b2f95 </div>
<div style="display:none"> Gerrit-Change-Number: 6424 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: Florian Floimair <f.floimair@commend.com> </div>
<div style="display:none"> Gerrit-Reviewer: Florian Floimair <f.floimair@commend.com> </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>