7f85dd44c775_fix_suppress_q850_reason_headers.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. """fix suppress_q850_reason_headers
  2. Revision ID: 7f85dd44c775
  3. Revises: fe6592859b85
  4. Create Date: 2018-09-18 16:16:29.304815
  5. """
  6. # revision identifiers, used by Alembic.
  7. revision = '7f85dd44c775'
  8. down_revision = 'fe6592859b85'
  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. yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=False)
  16. if op.get_context().bind.dialect.name != 'mssql':
  17. op.alter_column('ps_endpoints', 'suppress_q850_reason_header', type_=yesno_values,
  18. new_column_name='suppress_q850_reason_headers')
  19. else:
  20. op.alter_column('ps_endpoints', 'suppress_q850_reason_header', existing_type=yesno_values, type_=sa.String(3),
  21. new_column_name='suppress_q850_reason_headers')
  22. yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=True)
  23. op.alter_column('ps_endpoints', 'suppress_q850_reason_headers', existing_type=sa.String(3), type_=yesno_values)
  24. def downgrade():
  25. yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=False)
  26. if op.get_context().bind.dialect.name != 'mssql':
  27. op.alter_column('ps_endpoints', 'suppress_q850_reason_headers', type_=yesno_values,
  28. new_column_name='suppress_q850_reason_header')
  29. else:
  30. op.alter_column('ps_endpoints', 'suppress_q850_reason_headers', existing_type=yesno_values, type_=sa.String(3),
  31. new_column_name='suppress_q850_reason_header')
  32. yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=True)
  33. op.alter_column('ps_endpoints', 'suppress_q850_reason_header', existing_type=sa.String(3), type_=yesno_values)