From 91d39d32ced91d79ba5dcb9685c8d1b41297d27b Mon Sep 17 00:00:00 2001 From: "E. Belfer" <37471869+e-belfer@users.noreply.github.com> Date: Wed, 20 Mar 2024 12:29:00 -0700 Subject: [PATCH] Add FK exclusion for eia plants table (#3491) --- ...1bfda_exclude_923_fgd_table_from_860_fk.py | 34 +++++++++++++++++++ src/pudl/metadata/resources/eia860.py | 1 + 2 files changed, 35 insertions(+) create mode 100644 migrations/versions/41120381bfda_exclude_923_fgd_table_from_860_fk.py diff --git a/migrations/versions/41120381bfda_exclude_923_fgd_table_from_860_fk.py b/migrations/versions/41120381bfda_exclude_923_fgd_table_from_860_fk.py new file mode 100644 index 0000000000..6cb338e891 --- /dev/null +++ b/migrations/versions/41120381bfda_exclude_923_fgd_table_from_860_fk.py @@ -0,0 +1,34 @@ +"""Exclude 923 FGD table from 860 FK + +Revision ID: 41120381bfda +Revises: b8ae440a2d32 +Create Date: 2024-03-20 15:02:11.634526 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '41120381bfda' +down_revision = 'b8ae440a2d32' +branch_labels = None +depends_on = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('_core_eia923__fgd_operation_maintenance', schema=None) as batch_op: + batch_op.drop_constraint('fk__core_eia923__fgd_operation_maintenance_plant_id_eia_core_eia860__scd_plants', type_='foreignkey') + batch_op.create_foreign_key(batch_op.f('fk__core_eia923__fgd_operation_maintenance_plant_id_eia_core_eia__entity_plants'), 'core_eia__entity_plants', ['plant_id_eia'], ['plant_id_eia']) + + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('_core_eia923__fgd_operation_maintenance', schema=None) as batch_op: + batch_op.drop_constraint(batch_op.f('fk__core_eia923__fgd_operation_maintenance_plant_id_eia_core_eia__entity_plants'), type_='foreignkey') + batch_op.create_foreign_key('fk__core_eia923__fgd_operation_maintenance_plant_id_eia_core_eia860__scd_plants', 'core_eia860__scd_plants', ['plant_id_eia', 'report_date'], ['plant_id_eia', 'report_date']) + + # ### end Alembic commands ### diff --git a/src/pudl/metadata/resources/eia860.py b/src/pudl/metadata/resources/eia860.py index f3bfda74d8..6688899d39 100644 --- a/src/pudl/metadata/resources/eia860.py +++ b/src/pudl/metadata/resources/eia860.py @@ -373,6 +373,7 @@ # See: https://github.com/catalyst-cooperative/pudl/issues/1196 "exclude": [ "_core_eia923__cooling_system_information", + "_core_eia923__fgd_operation_maintenance", "core_eia923__monthly_boiler_fuel", "out_eia923__boiler_fuel", "out_eia923__monthly_boiler_fuel",