4c573e7135bd_fix_tos_field_types.py

Go to the documentation of this file.
00001 """Fix tos and cos field types
00002 
00003 Revision ID: 4c573e7135bd
00004 Revises: 28887f25a46f
00005 Create Date: 2014-03-05 12:16:56.618630
00006 
00007 """
00008 
00009 # revision identifiers, used by Alembic.
00010 revision = '4c573e7135bd'
00011 down_revision = '28887f25a46f'
00012 
00013 from alembic import op
00014 from alembic import context
00015 import sqlalchemy as sa
00016 from sqlalchemy.dialects.postgresql import ENUM
00017 
00018 YESNO_NAME = 'yesno_values'
00019 YESNO_VALUES = ['yes', 'no']
00020 
00021 def upgrade():
00022     op.alter_column('ps_endpoints', 'tos_audio',
00023                     type_=sa.String(10))
00024     op.alter_column('ps_endpoints', 'tos_video',
00025                     type_=sa.String(10))
00026     op.alter_column('ps_transports', 'tos',
00027                     type_=sa.String(10))
00028 
00029     # Can't cast YENO_VALUES to Integers, so dropping and adding is required
00030     op.drop_column('ps_endpoints', 'cos_audio')
00031     op.drop_column('ps_endpoints', 'cos_video')
00032     op.drop_column('ps_transports', 'cos')
00033 
00034     op.add_column('ps_endpoints', sa.Column('cos_audio', sa.Integer))
00035     op.add_column('ps_endpoints', sa.Column('cos_video', sa.Integer))
00036     op.add_column('ps_transports', sa.Column('cos', sa.Integer))
00037     pass
00038 
00039 
00040 def downgrade():
00041 
00042     yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=False)
00043 
00044     # Can't cast string to YESNO_VALUES, so dropping and adding is required
00045     op.drop_column('ps_endpoints', 'tos_audio')
00046     op.drop_column('ps_endpoints', 'tos_video')
00047     op.drop_column('ps_transports', 'tos')
00048 
00049     op.add_column('ps_endpoints', sa.Column('tos_audio', yesno_values))
00050     op.add_column('ps_endpoints', sa.Column('tos_video', yesno_values))
00051     op.add_column('ps_transports', sa.Column('tos', yesno_values))
00052 
00053     # Can't cast integers to YESNO_VALUES, so dropping and adding is required
00054     op.drop_column('ps_endpoints', 'cos_audio')
00055     op.drop_column('ps_endpoints', 'cos_video')
00056     op.drop_column('ps_transports', 'cos')
00057 
00058     op.add_column('ps_endpoints', sa.Column('cos_audio', yesno_values))
00059     op.add_column('ps_endpoints', sa.Column('cos_video', yesno_values))
00060     op.add_column('ps_transports', sa.Column('cos', yesno_values))
00061     pass

Generated on Thu Apr 16 06:27:05 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6