f638dbe2eb23_symmetric_transport.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. """symmetric_transport
  2. Revision ID: f638dbe2eb23
  3. Revises: 15db7b91a97a
  4. Create Date: 2017-03-09 09:38:59.513479
  5. """
  6. # revision identifiers, used by Alembic.
  7. revision = 'f638dbe2eb23'
  8. down_revision = '15db7b91a97a'
  9. from alembic import op
  10. import sqlalchemy as sa
  11. from sqlalchemy.dialects.postgresql import ENUM
  12. YESNO_NAME = 'yesno_values'
  13. YESNO_VALUES = ['yes', 'no']
  14. def upgrade():
  15. ############################# Enums ##############################
  16. # yesno_values have already been created, so use postgres enum object
  17. # type to get around "already created" issue - works okay with mysql
  18. yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=False)
  19. op.add_column('ps_transports', sa.Column('symmetric_transport', yesno_values))
  20. op.add_column('ps_subscription_persistence', sa.Column('contact_uri', sa.String(256)))
  21. def downgrade():
  22. op.drop_column('ps_subscription_persistence', 'contact_uri')
  23. if op.get_context().bind.dialect.name == 'mssql':
  24. op.drop_constraint('ck_ps_transports_symmetric_transport_yesno_values','ps_transports')
  25. op.drop_column('ps_transports', 'symmetric_transport')