2bb1a85135ad_pjsip_add_use_callerid_contact.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. """pjsip add use_callerid_contact
  2. Revision ID: 2bb1a85135ad
  3. Revises: 7f85dd44c775
  4. Create Date: 2018-10-18 15:13:40.462354
  5. """
  6. # revision identifiers, used by Alembic.
  7. revision = '2bb1a85135ad'
  8. down_revision = '7f85dd44c775'
  9. from alembic import op
  10. import sqlalchemy as sa
  11. from sqlalchemy.dialects.postgresql import ENUM
  12. AST_BOOL_NAME = 'ast_bool_values'
  13. # We'll just ignore the n/y and f/t abbreviations as Asterisk does not write
  14. # those aliases.
  15. AST_BOOL_VALUES = [ '0', '1',
  16. 'off', 'on',
  17. 'false', 'true',
  18. 'no', 'yes' ]
  19. def upgrade():
  20. ############################# Enums ##############################
  21. # ast_bool_values has already been created, so use postgres enum object
  22. # type to get around "already created" issue - works okay with mysql
  23. ast_bool_values = ENUM(*AST_BOOL_VALUES, name=AST_BOOL_NAME, create_type=False)
  24. op.add_column('ps_globals', sa.Column('use_callerid_contact', ast_bool_values))
  25. def downgrade():
  26. if op.get_context().bind.dialect.name == 'mssql':
  27. op.drop_constraint('ck_ps_globals_use_callerid_contact_ast_bool_values', 'ps_globals')
  28. op.drop_column('ps_globals', 'use_callerid_contact')