alembic: Fix use_callerid_contact option add script.

ASTERISK-28087

Change-Id: I046d018015427d0916fab571b5a4f5367476f729
This commit is contained in:
Richard Mudgett
2018-10-30 10:52:28 -05:00
parent 0b695d1e38
commit c81ffa9ec8

View File

@@ -24,19 +24,16 @@ AST_BOOL_VALUES = [ '0', '1',
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)