forked from catalyst-cooperative/pudl
-
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.
Add direct_support keys in `core_eia860__scd_generators_energy_storag…
…e` as foreign keys to `core_eia__entity_generators` (catalyst-cooperative#3699) * Add direct_support keys to FK * Try to harvest gen and plant IDs from direct storage cols * Add migrations * Fix mapped schemas * Make 3 migrations into 1, remove boiler mapped_schema * Update EIA row numbers * Update dependencies and fix new Ruff linting errors. * Add unmapped EIA plant IDs to mapping spreadsheet * Merge in main * Drop troublesome rows * Update row counts * Fix alembic migrations * Drop empty generator, reorder _out_eia__yearly_generators merge to drop rows with existing plant data, no generator data --------- Co-authored-by: Zane Selvans <[email protected]>
- Loading branch information
1 parent
30d23ac
commit e47be85
Showing
9 changed files
with
141 additions
and
12 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
migrations/versions/49d2f4f7d7b7_update_direct_support_plant_ids_to_.py
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,60 @@ | ||
"""Update direct_support plant IDs to integers, create FK relationship between direct support IDs and harvested entities | ||
Revision ID: 49d2f4f7d7b7 | ||
Revises: b9b6cb1a5405 | ||
Create Date: 2024-06-26 13:38:03.884714 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = '49d2f4f7d7b7' | ||
down_revision = 'aee9c15c7394' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
with op.batch_alter_table('core_eia860__scd_generators_energy_storage', schema=None) as batch_op: | ||
batch_op.alter_column('plant_id_eia_direct_support_1', | ||
existing_type=sa.FLOAT(), | ||
type_=sa.Integer(), | ||
existing_nullable=True) | ||
batch_op.alter_column('plant_id_eia_direct_support_2', | ||
existing_type=sa.FLOAT(), | ||
type_=sa.Integer(), | ||
existing_nullable=True) | ||
batch_op.alter_column('plant_id_eia_direct_support_3', | ||
existing_type=sa.FLOAT(), | ||
type_=sa.Integer(), | ||
existing_nullable=True) | ||
batch_op.create_foreign_key(batch_op.f('fk_core_eia860__scd_generators_energy_storage_plant_id_eia_direct_support_2_core_eia__entity_generators'), 'core_eia__entity_generators', ['plant_id_eia_direct_support_2', 'generator_id_direct_support_2'], ['plant_id_eia', 'generator_id']) | ||
batch_op.create_foreign_key(batch_op.f('fk_core_eia860__scd_generators_energy_storage_plant_id_eia_direct_support_1_core_eia__entity_generators'), 'core_eia__entity_generators', ['plant_id_eia_direct_support_1', 'generator_id_direct_support_1'], ['plant_id_eia', 'generator_id']) | ||
batch_op.create_foreign_key(batch_op.f('fk_core_eia860__scd_generators_energy_storage_plant_id_eia_direct_support_3_core_eia__entity_generators'), 'core_eia__entity_generators', ['plant_id_eia_direct_support_3', 'generator_id_direct_support_3'], ['plant_id_eia', 'generator_id']) | ||
|
||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
with op.batch_alter_table('core_eia860__scd_generators_energy_storage', schema=None) as batch_op: | ||
batch_op.drop_constraint(batch_op.f('fk_core_eia860__scd_generators_energy_storage_plant_id_eia_direct_support_3_core_eia__entity_generators'), type_='foreignkey') | ||
batch_op.drop_constraint(batch_op.f('fk_core_eia860__scd_generators_energy_storage_plant_id_eia_direct_support_1_core_eia__entity_generators'), type_='foreignkey') | ||
batch_op.drop_constraint(batch_op.f('fk_core_eia860__scd_generators_energy_storage_plant_id_eia_direct_support_2_core_eia__entity_generators'), type_='foreignkey') | ||
batch_op.alter_column('plant_id_eia_direct_support_3', | ||
existing_type=sa.Integer(), | ||
type_=sa.FLOAT(), | ||
existing_nullable=True) | ||
batch_op.alter_column('plant_id_eia_direct_support_2', | ||
existing_type=sa.Integer(), | ||
type_=sa.FLOAT(), | ||
existing_nullable=True) | ||
batch_op.alter_column('plant_id_eia_direct_support_1', | ||
existing_type=sa.Integer(), | ||
type_=sa.FLOAT(), | ||
existing_nullable=True) | ||
|
||
# ### end Alembic commands ### |
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
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
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
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
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
Binary file not shown.
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
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