Digitale bierlijst

b4f944f8dcf6_add_export_table.py 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. """Add Export table
  2. Revision ID: b4f944f8dcf6
  3. Revises: de101d627237
  4. Create Date: 2018-10-11 11:45:37.452396
  5. """
  6. from alembic import op
  7. import sqlalchemy as sa
  8. # revision identifiers, used by Alembic.
  9. revision = "b4f944f8dcf6"
  10. down_revision = "de101d627237"
  11. branch_labels = None
  12. depends_on = None
  13. def upgrade():
  14. op.create_table(
  15. "exports",
  16. sa.Column("export_id", sa.Integer(), nullable=False),
  17. sa.Column("created_at", sa.DateTime(), nullable=False),
  18. sa.PrimaryKeyConstraint("export_id"),
  19. )
  20. with op.batch_alter_table("settlements") as batch_op:
  21. batch_op.add_column(sa.Column("export_id", sa.Integer(), nullable=True))
  22. batch_op.create_foreign_key(
  23. "fk_settlements_exports", "exports", ["export_id"], ["export_id"]
  24. )
  25. def downgrade():
  26. with op.batch_alter_table("settlements") as batch_op:
  27. batch_op.drop_constraint("fk_settlements_exports", type_="foreignkey")
  28. batch_op.drop_column("export_id")
  29. op.drop_table("exports")