Asterisk - The Open Source Telephony Project  21.4.1
0bee61aa9425_allow_180_ringing_with_sdp.py
1 """allow_sending_180_after_183
2 
3 Revision ID: 0bee61aa9425
4 Revises: 8f72185e437f
5 Create Date: 2022-04-07 13:51:33.400664
6 
7 """
8 from alembic import op
9 import sqlalchemy as sa
10 from sqlalchemy.dialects.postgresql import ENUM
11 
12 # revision identifiers, used by Alembic.
13 revision = '0bee61aa9425'
14 down_revision = '8f72185e437f'
15 AST_BOOL_NAME = 'ast_bool_values'
16 # We'll just ignore the n/y and f/t abbreviations as Asterisk does not write
17 # those aliases.
18 AST_BOOL_VALUES = [ '0', '1',
19  'off', 'on',
20  'false', 'true',
21  'no', 'yes' ]
22 
23 def upgrade():
24  ############################# Enums ##############################
25 
26  # ast_bool_values has already been created, so use postgres enum object
27  # type to get around "already created" issue - works okay with mysql
28  ast_bool_values = ENUM(*AST_BOOL_VALUES, name=AST_BOOL_NAME, create_type=False)
29 
30  op.add_column('ps_globals', sa.Column('allow_sending_180_after_183', ast_bool_values))
31 
32 
33 def downgrade():
34  if op.get_context().bind.dialect.name == 'mssql':
35  op.drop_constraint('ck_ps_globals_allow_sending_180_after_183_ast_bool_values', 'ps_globals')
36  op.drop_column('ps_globals', 'allow_sending_180_after_183')