Skip to content

Commit

Permalink
Updated the alembic script ada681e1877f_create_fi_to_type_mapping_tab…
Browse files Browse the repository at this point in the history
…le to drop the sbl_institution_type_id

column, and to remove the FK and index.  On the downgrade, these are added back in.
  • Loading branch information
jcadam14 committed Jan 4, 2024
1 parent bc1f935 commit 24006e1
Showing 1 changed file with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,30 @@ def upgrade() -> None:
sa.Column("fi_id", sa.String(), sa.ForeignKey("financial_institutions.lei"), primary_key=True),
sa.Column("type_id", sa.String(), sa.ForeignKey("sbl_institution_type.id"), primary_key=True),
)

with op.batch_alter_table("financial_institutions") as batch_op:
batch_op.drop_constraint(
"fk_sbl_institution_type_financial_institutions",
type_="foreignkey"
)
batch_op.drop_index(
op.f("ix_financial_institutions_sbl_institution_type_id")
)
batch_op.drop_column(
"sbl_institution_type_id"
)

def downgrade() -> None:
op.drop_table("fi_to_type_mapping")
with op.batch_alter_table("financial_institutions") as batch_op:
batch_op.add_column(sa.Column("sbl_institution_type_id", sa.String(), nullable=True))
batch_op.create_foreign_key(
"fk_sbl_institution_type_financial_institutions",
"sbl_institution_type",
["sbl_institution_type_id"],
["id"],
)
batch_op.create_index(
op.f("ix_financial_institutions_sbl_institution_type_id"),
["sbl_institution_type_id"],
unique=False,
)

0 comments on commit 24006e1

Please sign in to comment.