23530d604b96_add_rpid_immediate.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #
  2. # Asterisk -- An open source telephony toolkit.
  3. #
  4. # Copyright (C) 2015, Richard Mudgett
  5. #
  6. # Richard Mudgett <rmudgett@digium.com>
  7. #
  8. # See http://www.asterisk.org for more information about
  9. # the Asterisk project. Please do not directly contact
  10. # any of the maintainers of this project for assistance;
  11. # the project provides a web site, mailing lists and IRC
  12. # channels for your use.
  13. #
  14. # This program is free software, distributed under the terms of
  15. # the GNU General Public License Version 2. See the LICENSE file
  16. # at the top of the source tree.
  17. #
  18. """add rpid_immediate
  19. Revision ID: 23530d604b96
  20. Revises: 45e3f47c6c44
  21. Create Date: 2015-03-18 17:41:58.055412
  22. """
  23. # revision identifiers, used by Alembic.
  24. revision = '23530d604b96'
  25. down_revision = '45e3f47c6c44'
  26. from alembic import op
  27. import sqlalchemy as sa
  28. from sqlalchemy.dialects.postgresql import ENUM
  29. YESNO_NAME = 'yesno_values'
  30. YESNO_VALUES = ['yes', 'no']
  31. def upgrade():
  32. ############################# Enums ##############################
  33. # yesno_values have already been created, so use postgres enum object
  34. # type to get around "already created" issue - works okay with mysql
  35. yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=False)
  36. op.add_column('ps_endpoints', sa.Column('rpid_immediate', yesno_values))
  37. def downgrade():
  38. if op.get_context().bind.dialect.name == 'mssql':
  39. op.drop_constraint('ck_ps_endpoints_rpid_immediate_yesno_values','ps_endpoints')
  40. op.drop_column('ps_endpoints', 'rpid_immediate')