Asterisk - The Open Source Telephony Project  18.5.0
7f85dd44c775_fix_suppress_q850_reason_headers.py
Go to the documentation of this file.
1 """fix suppress_q850_reason_headers
2 
3 Revision ID: 7f85dd44c775
4 Revises: fe6592859b85
5 Create Date: 2018-09-18 16:16:29.304815
6 
7 """
8 
9 # revision identifiers, used by Alembic.
10 revision = '7f85dd44c775'
11 down_revision = 'fe6592859b85'
12 
13 from alembic import op
14 import sqlalchemy as sa
15 from sqlalchemy.dialects.postgresql import ENUM
16 
17 YESNO_NAME = 'yesno_values'
18 YESNO_VALUES = ['yes', 'no']
19 
20 
21 def upgrade():
22  yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=False)
23 
24  if op.get_context().bind.dialect.name != 'mssql':
25  op.alter_column('ps_endpoints', 'suppress_q850_reason_header', type_=yesno_values,
26  new_column_name='suppress_q850_reason_headers')
27  else:
28  op.alter_column('ps_endpoints', 'suppress_q850_reason_header', existing_type=yesno_values, type_=sa.String(3),
29  new_column_name='suppress_q850_reason_headers')
30  yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=True)
31  op.alter_column('ps_endpoints', 'suppress_q850_reason_headers', existing_type=sa.String(3), type_=yesno_values)
32 
33 
34 def downgrade():
35  yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=False)
36  if op.get_context().bind.dialect.name != 'mssql':
37  op.alter_column('ps_endpoints', 'suppress_q850_reason_headers', type_=yesno_values,
38  new_column_name='suppress_q850_reason_header')
39  else:
40  op.alter_column('ps_endpoints', 'suppress_q850_reason_headers', existing_type=yesno_values, type_=sa.String(3),
41  new_column_name='suppress_q850_reason_header')
42  yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=True)
43  op.alter_column('ps_endpoints', 'suppress_q850_reason_header', existing_type=sa.String(3), type_=yesno_values)