"""Add Export table Revision ID: b4f944f8dcf6 Revises: de101d627237 Create Date: 2018-10-11 11:45:37.452396 """ from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. revision = "b4f944f8dcf6" down_revision = "de101d627237" branch_labels = None depends_on = None def upgrade(): op.create_table( "exports", sa.Column("export_id", sa.Integer(), nullable=False), sa.Column("created_at", sa.DateTime(), nullable=False), sa.PrimaryKeyConstraint("export_id"), ) with op.batch_alter_table("settlements") as batch_op: batch_op.add_column(sa.Column("export_id", sa.Integer(), nullable=True)) batch_op.create_foreign_key( "fk_settlements_exports", "exports", ["export_id"], ["export_id"] ) def downgrade(): with op.batch_alter_table("settlements") as batch_op: batch_op.drop_constraint("fk_settlements_exports", type_="foreignkey") batch_op.drop_column("export_id") op.drop_table("exports")