0c526a49471c_add_capital_relation_to_state.py 665 B

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