generated from communitiesuk/funding-service-design-TEMPLATE
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #738 from communitiesuk/fpasf-494/remove-old-repor…
…ting-round-cols-migration Fpasf 494/remove old reporting round cols migration
- Loading branch information
Showing
2 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
043_non_nullable_reporting_round | ||
044_remove_old_rr_cols |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] | ||
) |