Asterisk - The Open Source Telephony Project GIT-master-f36a736
7f85dd44c775_fix_suppress_q850_reason_headers.py
Go to the documentation of this file.
1"""fix suppress_q850_reason_headers
2
3Revision ID: 7f85dd44c775
4Revises: fe6592859b85
5Create Date: 2018-09-18 16:16:29.304815
6
7"""
8
9# revision identifiers, used by Alembic.
10revision = '7f85dd44c775'
11down_revision = 'fe6592859b85'
12
13from alembic import op
14import sqlalchemy as sa
15from sqlalchemy.dialects.postgresql import ENUM
16
17YESNO_NAME = 'yesno_values'
18YESNO_VALUES = ['yes', 'no']
19
20
21def 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
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)