82a809b72bf3_add_state_to_department.py 676 B

1234567891011121314151617181920212223242526
  1. """add state to department
  2. Revision ID: 82a809b72bf3
  3. Revises: 0c526a49471c
  4. Create Date: 2019-09-03 15:07:27.138712
  5. """
  6. from alembic import op
  7. import sqlalchemy as sa
  8. # revision identifiers, used by Alembic.
  9. revision = '82a809b72bf3'
  10. down_revision = '0c526a49471c'
  11. branch_labels = None
  12. depends_on = None
  13. def upgrade():
  14. op.add_column('department', sa.Column('state_id', sa.Integer(), nullable=True))
  15. op.create_foreign_key(op.f('fk_department_state_id_state'), 'department', 'state', ['state_id'], ['id'])
  16. def downgrade():
  17. op.drop_constraint(op.f('fk_department_state_id_state'), 'department', type_='foreignkey')
  18. op.drop_column('department', 'state_id')