661865b159c9_state_to_region.py 1.1 KB

123456789101112131415161718192021222324252627282930
  1. """state_to_region
  2. Revision ID: 661865b159c9
  3. Revises: 376b13137050
  4. Create Date: 2019-10-17 23:11:16.074823
  5. """
  6. from alembic import op
  7. import sqlalchemy as sa
  8. # revision identifiers, used by Alembic.
  9. revision = '661865b159c9'
  10. down_revision = '376b13137050'
  11. branch_labels = None
  12. depends_on = None
  13. def upgrade():
  14. op.add_column('state_market_stat', sa.Column('region_id', sa.Integer(), nullable=True))
  15. op.drop_constraint('fk_state_market_stat_state_id_state', 'state_market_stat', type_='foreignkey')
  16. op.create_foreign_key(op.f('fk_state_market_stat_region_id_region'), 'state_market_stat', 'region', ['region_id'], ['id'])
  17. op.drop_column('state_market_stat', 'state_id')
  18. def downgrade():
  19. op.add_column('state_market_stat', sa.Column('state_id', sa.INTEGER(), autoincrement=False, nullable=True))
  20. op.drop_constraint(op.f('fk_state_market_stat_region_id_region'), 'state_market_stat', type_='foreignkey')
  21. op.create_foreign_key('fk_state_market_stat_state_id_state', 'state_market_stat', 'state', ['state_id'], ['id'])
  22. op.drop_column('state_market_stat', 'region_id')