Asterisk - The Open Source Telephony Project  18.5.0
5950038a6ead_fix_pjsip_verifiy_typo.py
Go to the documentation of this file.
1 """Fix pjsip transports verify column
2 
3 Revision ID: 5950038a6ead
4 Revises: d39508cb8d8
5 Create Date: 2014-09-15 06:21:35.047314
6 
7 """
8 
9 # revision identifiers, used by Alembic.
10 revision = '5950038a6ead'
11 down_revision = 'd39508cb8d8'
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 def upgrade():
21  yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=False)
22 
23  if op.get_context().bind.dialect.name != 'mssql':
24  op.alter_column('ps_transports', 'verifiy_server', type_=yesno_values,
25  new_column_name='verify_server')
26  else:
27  op.alter_column('ps_transports', 'verifiy_server', existing_type=yesno_values, type_=sa.String(3),
28  new_column_name='verify_server')
29  yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=True)
30  op.alter_column('ps_transports', 'verify_server', existing_type=sa.String(3), type_=yesno_values)
31 
32 
33 def downgrade():
34  yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=False)
35  if op.get_context().bind.dialect.name != 'mssql':
36  op.alter_column('ps_transports', 'verify_server', type_=yesno_values,
37  new_column_name='verifiy_server')
38  else:
39  op.alter_column('ps_transports', 'verify_server', existing_type=yesno_values, type_=sa.String(3),
40  new_column_name='verifiy_server')
41  yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=True)
42  op.alter_column('ps_transports', 'verifiy_server', existing_type=sa.String(3), type_=yesno_values)