[Asterisk-code-review] alembic: Fix use callerid contact option add script. (asterisk[13])

George Joseph asteriskteam at digium.com
Wed Oct 31 13:58:12 CDT 2018


George Joseph has submitted this change and it was merged. ( https://gerrit.asterisk.org/10568 )

Change subject: alembic: Fix use_callerid_contact option add script.
......................................................................

alembic: Fix use_callerid_contact option add script.

ASTERISK-28087

Change-Id: I046d018015427d0916fab571b5a4f5367476f729
---
M contrib/ast-db-manage/config/versions/2bb1a85135ad_pjsip_add_use_callerid_contact.py
1 file changed, 5 insertions(+), 8 deletions(-)

Approvals:
  Benjamin Keith Ford: Looks good to me, but someone else must approve
  Sean Bright: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved; Approved for Submit



diff --git a/contrib/ast-db-manage/config/versions/2bb1a85135ad_pjsip_add_use_callerid_contact.py b/contrib/ast-db-manage/config/versions/2bb1a85135ad_pjsip_add_use_callerid_contact.py
index 490e23d..a2d39f4 100644
--- a/contrib/ast-db-manage/config/versions/2bb1a85135ad_pjsip_add_use_callerid_contact.py
+++ b/contrib/ast-db-manage/config/versions/2bb1a85135ad_pjsip_add_use_callerid_contact.py
@@ -24,19 +24,16 @@
 
 
 def upgrade():
-    # Create the new enum
-    ast_bool_values = ENUM(*AST_BOOL_VALUES, name=AST_BOOL_NAME, create_type=False)
-    if op.get_context().bind.dialect.name == 'postgresql':
-        ast_bool_values.create(op.get_bind(), checkfirst=False)
+    ############################# Enums ##############################
 
+    # ast_bool_values has already been created, so use postgres enum object
+    # type to get around "already created" issue - works okay with mysql
+    ast_bool_values = ENUM(*AST_BOOL_VALUES, name=AST_BOOL_NAME, create_type=False)
 
     op.add_column('ps_globals', sa.Column('use_callerid_contact', ast_bool_values))
 
 
 def downgrade():
     if op.get_context().bind.dialect.name == 'mssql':
-        op.drop_constraint('ck_ps_globals_use_callerid_contact_ast_bool_values','ps_globals')
+        op.drop_constraint('ck_ps_globals_use_callerid_contact_ast_bool_values', 'ps_globals')
     op.drop_column('ps_globals', 'use_callerid_contact')
-
-    if op.get_context().bind.dialect.name == 'postgresql':
-        ENUM(name=AST_BOOL_NAME).drop(op.get_bind(), checkfirst=False)

-- 
To view, visit https://gerrit.asterisk.org/10568
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: merged
Gerrit-Change-Id: I046d018015427d0916fab571b5a4f5367476f729
Gerrit-Change-Number: 10568
Gerrit-PatchSet: 1
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Benjamin Keith Ford <bford at digium.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2 (1000185)
Gerrit-Reviewer: Sean Bright <sean.bright at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20181031/dccd0edf/attachment.html>


More information about the asterisk-code-review mailing list