Skip to content

Commit

Permalink
Merge pull request #738 from communitiesuk/fpasf-494/remove-old-repor…
Browse files Browse the repository at this point in the history
…ting-round-cols-migration

Fpasf 494/remove old reporting round cols migration
  • Loading branch information
samuelhwilliams authored Sep 25, 2024
2 parents 5250b6c + 3536a83 commit 2039950
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
2 changes: 1 addition & 1 deletion db/migrations/.current-alembic-head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
043_non_nullable_reporting_round
044_remove_old_rr_cols
51 changes: 51 additions & 0 deletions db/migrations/versions/044_remove_old_rr_cols.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"""remove old rr cols
Revision ID: 044_remove_old_rr_cols
Revises: 043_non_nullable_reporting_round
Create Date: 2024-09-24 17:44:36.150473
"""

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "044_remove_old_rr_cols"
down_revision = "043_non_nullable_reporting_round"
branch_labels = None
depends_on = None


def upgrade():
with op.batch_alter_table("programme_junction", schema=None) as batch_op:
batch_op.drop_constraint("uq_programme_junction_programme_id_reporting_round_id", type_="unique")
batch_op.drop_constraint("uq_programme_junction_unique_submission_per_round", type_="unique")
batch_op.drop_column("reporting_round")

with op.batch_alter_table("submission_dim", schema=None) as batch_op:
batch_op.drop_index("ix_submission_filter_end_date")
batch_op.drop_index("ix_submission_filter_start_date")
batch_op.drop_column("reporting_period_start")
batch_op.drop_column("reporting_period_end")


def downgrade():
with op.batch_alter_table("submission_dim", schema=None) as batch_op:
batch_op.add_column(
sa.Column("reporting_period_end", postgresql.TIMESTAMP(), autoincrement=False, nullable=True)
)
batch_op.add_column(
sa.Column("reporting_period_start", postgresql.TIMESTAMP(), autoincrement=False, nullable=True)
)
batch_op.create_index("ix_submission_filter_start_date", ["reporting_period_start"], unique=False)
batch_op.create_index("ix_submission_filter_end_date", ["reporting_period_end"], unique=False)

with op.batch_alter_table("programme_junction", schema=None) as batch_op:
batch_op.add_column(sa.Column("reporting_round", sa.INTEGER(), autoincrement=False, nullable=True))
batch_op.create_unique_constraint(
"uq_programme_junction_unique_submission_per_round", ["programme_id", "reporting_round"]
)
batch_op.create_unique_constraint(
"uq_programme_junction_programme_id_reporting_round_id", ["programme_id", "reporting_round_id"]
)

0 comments on commit 2039950

Please sign in to comment.