From 7ef9c70274b9ad7f7e1f8553fe7f0d480df3f577 Mon Sep 17 00:00:00 2001 From: bendnorman Date: Wed, 15 Nov 2023 14:11:53 -0900 Subject: [PATCH] Recreate heat rate migration revision --- ...23_add_unit__to_heat_rate_mmbtu_per_mwh.py | 247 -------------- ...bd_add_unit__to_heat_rate_mmbtu_per_mwh.py | 305 ++++++++++++++++++ 2 files changed, 305 insertions(+), 247 deletions(-) delete mode 100644 migrations/versions/9ccfb2eb8d23_add_unit__to_heat_rate_mmbtu_per_mwh.py create mode 100644 migrations/versions/ccdf68a30cbd_add_unit__to_heat_rate_mmbtu_per_mwh.py diff --git a/migrations/versions/9ccfb2eb8d23_add_unit__to_heat_rate_mmbtu_per_mwh.py b/migrations/versions/9ccfb2eb8d23_add_unit__to_heat_rate_mmbtu_per_mwh.py deleted file mode 100644 index 710a4eb2e0..0000000000 --- a/migrations/versions/9ccfb2eb8d23_add_unit__to_heat_rate_mmbtu_per_mwh.py +++ /dev/null @@ -1,247 +0,0 @@ -"""Add unit_ to heat_rate_mmbtu_per_mwh - -Revision ID: 9ccfb2eb8d23 -Revises: 1fef7b82e48b -Create Date: 2023-11-15 10:27:27.709921 - -""" -import sqlalchemy as sa -from alembic import op - -# revision identifiers, used by Alembic. -revision = '9ccfb2eb8d23' -down_revision = '1fef7b82e48b' -branch_labels = None -depends_on = None - - -def upgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('_out_eia__monthly_derived_generator_attributes', schema=None) as batch_op: - batch_op.add_column(sa.Column('unit_heat_rate_mmbtu_per_mwh', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) - batch_op.drop_column('heat_rate_mmbtu_mwh') - - with op.batch_alter_table('_out_eia__monthly_fuel_cost_by_generator', schema=None) as batch_op: - batch_op.add_column(sa.Column('unit_heat_rate_mmbtu_per_mwh', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) - batch_op.drop_column('heat_rate_mmbtu_mwh') - - with op.batch_alter_table('_out_eia__monthly_heat_rate_by_generator', schema=None) as batch_op: - batch_op.add_column(sa.Column('unit_heat_rate_mmbtu_per_mwh', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) - batch_op.drop_column('heat_rate_mmbtu_mwh') - - with op.batch_alter_table('_out_eia__monthly_heat_rate_by_unit', schema=None) as batch_op: - batch_op.add_column(sa.Column('unit_heat_rate_mmbtu_per_mwh', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) - batch_op.drop_column('heat_rate_mmbtu_mwh') - - with op.batch_alter_table('_out_eia__plants_utilities', schema=None) as batch_op: - batch_op.add_column(sa.Column('data_maturity', sa.Text(), nullable=True, comment='Level of maturity of the data record. Some data sources report less-than-final data. PUDL sometimes includes this data, but use at your own risk.')) - batch_op.create_foreign_key(batch_op.f('fk__out_eia__plants_utilities_data_maturity_core_pudl__codes_data_maturities'), 'core_pudl__codes_data_maturities', ['data_maturity'], ['code']) - - with op.batch_alter_table('_out_eia__yearly_derived_generator_attributes', schema=None) as batch_op: - batch_op.add_column(sa.Column('unit_heat_rate_mmbtu_per_mwh', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) - batch_op.drop_column('heat_rate_mmbtu_mwh') - - with op.batch_alter_table('_out_eia__yearly_fuel_cost_by_generator', schema=None) as batch_op: - batch_op.add_column(sa.Column('unit_heat_rate_mmbtu_per_mwh', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) - batch_op.drop_column('heat_rate_mmbtu_mwh') - - with op.batch_alter_table('_out_eia__yearly_heat_rate_by_generator', schema=None) as batch_op: - batch_op.add_column(sa.Column('unit_heat_rate_mmbtu_per_mwh', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) - batch_op.drop_column('heat_rate_mmbtu_mwh') - - with op.batch_alter_table('_out_eia__yearly_heat_rate_by_unit', schema=None) as batch_op: - batch_op.add_column(sa.Column('unit_heat_rate_mmbtu_per_mwh', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) - batch_op.drop_column('heat_rate_mmbtu_mwh') - - with op.batch_alter_table('core_eia923__monthly_boiler_fuel', schema=None) as batch_op: - batch_op.add_column(sa.Column('data_maturity', sa.Text(), nullable=True, comment='Level of maturity of the data record. Some data sources report less-than-final data. PUDL sometimes includes this data, but use at your own risk.')) - batch_op.create_foreign_key(batch_op.f('fk_core_eia923__monthly_boiler_fuel_data_maturity_core_pudl__codes_data_maturities'), 'core_pudl__codes_data_maturities', ['data_maturity'], ['code']) - - with op.batch_alter_table('core_ferc714__hourly_demand_pa', schema=None) as batch_op: - batch_op.alter_column('report_date', - existing_type=sa.DATE(), - nullable=False) - - with op.batch_alter_table('mega_generators_eia', schema=None) as batch_op: - batch_op.add_column(sa.Column('unit_heat_rate_mmbtu_per_mwh', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) - batch_op.drop_column('heat_rate_mmbtu_mwh') - - with op.batch_alter_table('out_eia923__boiler_fuel', schema=None) as batch_op: - batch_op.add_column(sa.Column('data_maturity', sa.Text(), nullable=True, comment='Level of maturity of the data record. Some data sources report less-than-final data. PUDL sometimes includes this data, but use at your own risk.')) - batch_op.create_foreign_key(batch_op.f('fk_out_eia923__boiler_fuel_data_maturity_core_pudl__codes_data_maturities'), 'core_pudl__codes_data_maturities', ['data_maturity'], ['code']) - - with op.batch_alter_table('out_eia923__monthly_boiler_fuel', schema=None) as batch_op: - batch_op.add_column(sa.Column('data_maturity', sa.Text(), nullable=True, comment='Level of maturity of the data record. Some data sources report less-than-final data. PUDL sometimes includes this data, but use at your own risk.')) - batch_op.create_foreign_key(batch_op.f('fk_out_eia923__monthly_boiler_fuel_data_maturity_core_pudl__codes_data_maturities'), 'core_pudl__codes_data_maturities', ['data_maturity'], ['code']) - - with op.batch_alter_table('out_eia923__monthly_fuel_receipts_costs', schema=None) as batch_op: - batch_op.add_column(sa.Column('data_maturity', sa.Text(), nullable=True, comment='Level of maturity of the data record. Some data sources report less-than-final data. PUDL sometimes includes this data, but use at your own risk.')) - batch_op.create_foreign_key(batch_op.f('fk_out_eia923__monthly_fuel_receipts_costs_data_maturity_core_pudl__codes_data_maturities'), 'core_pudl__codes_data_maturities', ['data_maturity'], ['code']) - - with op.batch_alter_table('out_eia923__monthly_generation', schema=None) as batch_op: - batch_op.add_column(sa.Column('data_maturity', sa.Text(), nullable=True, comment='Level of maturity of the data record. Some data sources report less-than-final data. PUDL sometimes includes this data, but use at your own risk.')) - batch_op.create_foreign_key(batch_op.f('fk_out_eia923__monthly_generation_data_maturity_core_pudl__codes_data_maturities'), 'core_pudl__codes_data_maturities', ['data_maturity'], ['code']) - - with op.batch_alter_table('out_eia923__monthly_generation_fuel_combined', schema=None) as batch_op: - batch_op.add_column(sa.Column('data_maturity', sa.Text(), nullable=True, comment='Level of maturity of the data record. Some data sources report less-than-final data. PUDL sometimes includes this data, but use at your own risk.')) - batch_op.create_foreign_key(batch_op.f('fk_out_eia923__monthly_generation_fuel_combined_data_maturity_core_pudl__codes_data_maturities'), 'core_pudl__codes_data_maturities', ['data_maturity'], ['code']) - - with op.batch_alter_table('out_eia923__yearly_boiler_fuel', schema=None) as batch_op: - batch_op.add_column(sa.Column('data_maturity', sa.Text(), nullable=True, comment='Level of maturity of the data record. Some data sources report less-than-final data. PUDL sometimes includes this data, but use at your own risk.')) - batch_op.create_foreign_key(batch_op.f('fk_out_eia923__yearly_boiler_fuel_data_maturity_core_pudl__codes_data_maturities'), 'core_pudl__codes_data_maturities', ['data_maturity'], ['code']) - - with op.batch_alter_table('out_eia923__yearly_fuel_receipts_costs', schema=None) as batch_op: - batch_op.add_column(sa.Column('data_maturity', sa.Text(), nullable=True, comment='Level of maturity of the data record. Some data sources report less-than-final data. PUDL sometimes includes this data, but use at your own risk.')) - batch_op.create_foreign_key(batch_op.f('fk_out_eia923__yearly_fuel_receipts_costs_data_maturity_core_pudl__codes_data_maturities'), 'core_pudl__codes_data_maturities', ['data_maturity'], ['code']) - - with op.batch_alter_table('out_eia923__yearly_generation', schema=None) as batch_op: - batch_op.add_column(sa.Column('data_maturity', sa.Text(), nullable=True, comment='Level of maturity of the data record. Some data sources report less-than-final data. PUDL sometimes includes this data, but use at your own risk.')) - batch_op.create_foreign_key(batch_op.f('fk_out_eia923__yearly_generation_data_maturity_core_pudl__codes_data_maturities'), 'core_pudl__codes_data_maturities', ['data_maturity'], ['code']) - - with op.batch_alter_table('out_eia923__yearly_generation_fuel_combined', schema=None) as batch_op: - batch_op.add_column(sa.Column('data_maturity', sa.Text(), nullable=True, comment='Level of maturity of the data record. Some data sources report less-than-final data. PUDL sometimes includes this data, but use at your own risk.')) - batch_op.create_foreign_key(batch_op.f('fk_out_eia923__yearly_generation_fuel_combined_data_maturity_core_pudl__codes_data_maturities'), 'core_pudl__codes_data_maturities', ['data_maturity'], ['code']) - - with op.batch_alter_table('out_eia__monthly_generators', schema=None) as batch_op: - batch_op.add_column(sa.Column('unit_heat_rate_mmbtu_per_mwh', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) - batch_op.drop_column('heat_rate_mmbtu_mwh') - - with op.batch_alter_table('out_eia__yearly_generators', schema=None) as batch_op: - batch_op.add_column(sa.Column('unit_heat_rate_mmbtu_per_mwh', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) - batch_op.drop_column('heat_rate_mmbtu_mwh') - - with op.batch_alter_table('out_eia__yearly_generators_by_ownership', schema=None) as batch_op: - batch_op.add_column(sa.Column('unit_heat_rate_mmbtu_per_mwh', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) - batch_op.drop_column('heat_rate_mmbtu_mwh') - - with op.batch_alter_table('out_eia__yearly_plant_parts', schema=None) as batch_op: - batch_op.add_column(sa.Column('unit_heat_rate_mmbtu_per_mwh', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) - batch_op.drop_column('heat_rate_mmbtu_mwh') - - with op.batch_alter_table('out_pudl__yearly_assn_eia_ferc1_plant_parts', schema=None) as batch_op: - batch_op.add_column(sa.Column('unit_heat_rate_mmbtu_per_mwh_eia', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) - batch_op.add_column(sa.Column('unit_heat_rate_mmbtu_per_mwh_ferc1', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Calculated from FERC reported fuel consumption and net generation.')) - batch_op.drop_column('heat_rate_mmbtu_mwh_eia') - batch_op.drop_column('heat_rate_mmbtu_mwh_ferc1') - - with op.batch_alter_table('plant_parts_eia', schema=None) as batch_op: - batch_op.add_column(sa.Column('unit_heat_rate_mmbtu_per_mwh', sa.Float(), nullable=True, comment='Fuel content per unit of electricity generated. Coming from MCOE calculation.')) - batch_op.drop_column('heat_rate_mmbtu_mwh') - - # ### end Alembic commands ### - - -def downgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('plant_parts_eia', schema=None) as batch_op: - batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh', sa.FLOAT(), nullable=True)) - batch_op.drop_column('unit_heat_rate_mmbtu_per_mwh') - - with op.batch_alter_table('out_pudl__yearly_assn_eia_ferc1_plant_parts', schema=None) as batch_op: - batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh_ferc1', sa.FLOAT(), nullable=True)) - batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh_eia', sa.FLOAT(), nullable=True)) - batch_op.drop_column('unit_heat_rate_mmbtu_per_mwh_ferc1') - batch_op.drop_column('unit_heat_rate_mmbtu_per_mwh_eia') - - with op.batch_alter_table('out_eia__yearly_plant_parts', schema=None) as batch_op: - batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh', sa.FLOAT(), nullable=True)) - batch_op.drop_column('unit_heat_rate_mmbtu_per_mwh') - - with op.batch_alter_table('out_eia__yearly_generators_by_ownership', schema=None) as batch_op: - batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh', sa.FLOAT(), nullable=True)) - batch_op.drop_column('unit_heat_rate_mmbtu_per_mwh') - - with op.batch_alter_table('out_eia__yearly_generators', schema=None) as batch_op: - batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh', sa.FLOAT(), nullable=True)) - batch_op.drop_column('unit_heat_rate_mmbtu_per_mwh') - - with op.batch_alter_table('out_eia__monthly_generators', schema=None) as batch_op: - batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh', sa.FLOAT(), nullable=True)) - batch_op.drop_column('unit_heat_rate_mmbtu_per_mwh') - - with op.batch_alter_table('out_eia923__yearly_generation_fuel_combined', schema=None) as batch_op: - batch_op.drop_constraint(batch_op.f('fk_out_eia923__yearly_generation_fuel_combined_data_maturity_core_pudl__codes_data_maturities'), type_='foreignkey') - batch_op.drop_column('data_maturity') - - with op.batch_alter_table('out_eia923__yearly_generation', schema=None) as batch_op: - batch_op.drop_constraint(batch_op.f('fk_out_eia923__yearly_generation_data_maturity_core_pudl__codes_data_maturities'), type_='foreignkey') - batch_op.drop_column('data_maturity') - - with op.batch_alter_table('out_eia923__yearly_fuel_receipts_costs', schema=None) as batch_op: - batch_op.drop_constraint(batch_op.f('fk_out_eia923__yearly_fuel_receipts_costs_data_maturity_core_pudl__codes_data_maturities'), type_='foreignkey') - batch_op.drop_column('data_maturity') - - with op.batch_alter_table('out_eia923__yearly_boiler_fuel', schema=None) as batch_op: - batch_op.drop_constraint(batch_op.f('fk_out_eia923__yearly_boiler_fuel_data_maturity_core_pudl__codes_data_maturities'), type_='foreignkey') - batch_op.drop_column('data_maturity') - - with op.batch_alter_table('out_eia923__monthly_generation_fuel_combined', schema=None) as batch_op: - batch_op.drop_constraint(batch_op.f('fk_out_eia923__monthly_generation_fuel_combined_data_maturity_core_pudl__codes_data_maturities'), type_='foreignkey') - batch_op.drop_column('data_maturity') - - with op.batch_alter_table('out_eia923__monthly_generation', schema=None) as batch_op: - batch_op.drop_constraint(batch_op.f('fk_out_eia923__monthly_generation_data_maturity_core_pudl__codes_data_maturities'), type_='foreignkey') - batch_op.drop_column('data_maturity') - - with op.batch_alter_table('out_eia923__monthly_fuel_receipts_costs', schema=None) as batch_op: - batch_op.drop_constraint(batch_op.f('fk_out_eia923__monthly_fuel_receipts_costs_data_maturity_core_pudl__codes_data_maturities'), type_='foreignkey') - batch_op.drop_column('data_maturity') - - with op.batch_alter_table('out_eia923__monthly_boiler_fuel', schema=None) as batch_op: - batch_op.drop_constraint(batch_op.f('fk_out_eia923__monthly_boiler_fuel_data_maturity_core_pudl__codes_data_maturities'), type_='foreignkey') - batch_op.drop_column('data_maturity') - - with op.batch_alter_table('out_eia923__boiler_fuel', schema=None) as batch_op: - batch_op.drop_constraint(batch_op.f('fk_out_eia923__boiler_fuel_data_maturity_core_pudl__codes_data_maturities'), type_='foreignkey') - batch_op.drop_column('data_maturity') - - with op.batch_alter_table('mega_generators_eia', schema=None) as batch_op: - batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh', sa.FLOAT(), nullable=True)) - batch_op.drop_column('unit_heat_rate_mmbtu_per_mwh') - - with op.batch_alter_table('core_ferc714__hourly_demand_pa', schema=None) as batch_op: - batch_op.alter_column('report_date', - existing_type=sa.DATE(), - nullable=True) - - with op.batch_alter_table('core_eia923__monthly_boiler_fuel', schema=None) as batch_op: - batch_op.drop_constraint(batch_op.f('fk_core_eia923__monthly_boiler_fuel_data_maturity_core_pudl__codes_data_maturities'), type_='foreignkey') - batch_op.drop_column('data_maturity') - - with op.batch_alter_table('_out_eia__yearly_heat_rate_by_unit', schema=None) as batch_op: - batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh', sa.FLOAT(), nullable=True)) - batch_op.drop_column('unit_heat_rate_mmbtu_per_mwh') - - with op.batch_alter_table('_out_eia__yearly_heat_rate_by_generator', schema=None) as batch_op: - batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh', sa.FLOAT(), nullable=True)) - batch_op.drop_column('unit_heat_rate_mmbtu_per_mwh') - - with op.batch_alter_table('_out_eia__yearly_fuel_cost_by_generator', schema=None) as batch_op: - batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh', sa.FLOAT(), nullable=True)) - batch_op.drop_column('unit_heat_rate_mmbtu_per_mwh') - - with op.batch_alter_table('_out_eia__yearly_derived_generator_attributes', schema=None) as batch_op: - batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh', sa.FLOAT(), nullable=True)) - batch_op.drop_column('unit_heat_rate_mmbtu_per_mwh') - - with op.batch_alter_table('_out_eia__plants_utilities', schema=None) as batch_op: - batch_op.drop_constraint(batch_op.f('fk__out_eia__plants_utilities_data_maturity_core_pudl__codes_data_maturities'), type_='foreignkey') - batch_op.drop_column('data_maturity') - - with op.batch_alter_table('_out_eia__monthly_heat_rate_by_unit', schema=None) as batch_op: - batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh', sa.FLOAT(), nullable=True)) - batch_op.drop_column('unit_heat_rate_mmbtu_per_mwh') - - with op.batch_alter_table('_out_eia__monthly_heat_rate_by_generator', schema=None) as batch_op: - batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh', sa.FLOAT(), nullable=True)) - batch_op.drop_column('unit_heat_rate_mmbtu_per_mwh') - - with op.batch_alter_table('_out_eia__monthly_fuel_cost_by_generator', schema=None) as batch_op: - batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh', sa.FLOAT(), nullable=True)) - batch_op.drop_column('unit_heat_rate_mmbtu_per_mwh') - - with op.batch_alter_table('_out_eia__monthly_derived_generator_attributes', schema=None) as batch_op: - batch_op.add_column(sa.Column('heat_rate_mmbtu_mwh', sa.FLOAT(), nullable=True)) - batch_op.drop_column('unit_heat_rate_mmbtu_per_mwh') - - # ### end Alembic commands ### diff --git a/migrations/versions/ccdf68a30cbd_add_unit__to_heat_rate_mmbtu_per_mwh.py b/migrations/versions/ccdf68a30cbd_add_unit__to_heat_rate_mmbtu_per_mwh.py new file mode 100644 index 0000000000..ffd41d29eb --- /dev/null +++ b/migrations/versions/ccdf68a30cbd_add_unit__to_heat_rate_mmbtu_per_mwh.py @@ -0,0 +1,305 @@ +"""Add unit_ to heat_rate_mmbtu_per_mwh + +Revision ID: ccdf68a30cbd +Revises: 9edc4a11c809 +Create Date: 2023-11-15 14:09:59.541894 + +""" +import sqlalchemy as sa +from alembic import op + +# revision identifiers, used by Alembic. +revision = "ccdf68a30cbd" +down_revision = "9edc4a11c809" +branch_labels = None +depends_on = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table( + "_out_eia__monthly_derived_generator_attributes", schema=None + ) as batch_op: + batch_op.add_column( + sa.Column( + "unit_heat_rate_mmbtu_per_mwh", + sa.Float(), + nullable=True, + comment="Fuel content per unit of electricity generated. Coming from MCOE calculation.", + ) + ) + batch_op.drop_column("heat_rate_mmbtu_mwh") + + with op.batch_alter_table( + "_out_eia__monthly_fuel_cost_by_generator", schema=None + ) as batch_op: + batch_op.add_column( + sa.Column( + "unit_heat_rate_mmbtu_per_mwh", + sa.Float(), + nullable=True, + comment="Fuel content per unit of electricity generated. Coming from MCOE calculation.", + ) + ) + batch_op.drop_column("heat_rate_mmbtu_mwh") + + with op.batch_alter_table( + "_out_eia__monthly_heat_rate_by_generator", schema=None + ) as batch_op: + batch_op.add_column( + sa.Column( + "unit_heat_rate_mmbtu_per_mwh", + sa.Float(), + nullable=True, + comment="Fuel content per unit of electricity generated. Coming from MCOE calculation.", + ) + ) + batch_op.drop_column("heat_rate_mmbtu_mwh") + + with op.batch_alter_table( + "_out_eia__monthly_heat_rate_by_unit", schema=None + ) as batch_op: + batch_op.add_column( + sa.Column( + "unit_heat_rate_mmbtu_per_mwh", + sa.Float(), + nullable=True, + comment="Fuel content per unit of electricity generated. Coming from MCOE calculation.", + ) + ) + batch_op.drop_column("heat_rate_mmbtu_mwh") + + with op.batch_alter_table( + "_out_eia__yearly_derived_generator_attributes", schema=None + ) as batch_op: + batch_op.add_column( + sa.Column( + "unit_heat_rate_mmbtu_per_mwh", + sa.Float(), + nullable=True, + comment="Fuel content per unit of electricity generated. Coming from MCOE calculation.", + ) + ) + batch_op.drop_column("heat_rate_mmbtu_mwh") + + with op.batch_alter_table( + "_out_eia__yearly_fuel_cost_by_generator", schema=None + ) as batch_op: + batch_op.add_column( + sa.Column( + "unit_heat_rate_mmbtu_per_mwh", + sa.Float(), + nullable=True, + comment="Fuel content per unit of electricity generated. Coming from MCOE calculation.", + ) + ) + batch_op.drop_column("heat_rate_mmbtu_mwh") + + with op.batch_alter_table( + "_out_eia__yearly_heat_rate_by_generator", schema=None + ) as batch_op: + batch_op.add_column( + sa.Column( + "unit_heat_rate_mmbtu_per_mwh", + sa.Float(), + nullable=True, + comment="Fuel content per unit of electricity generated. Coming from MCOE calculation.", + ) + ) + batch_op.drop_column("heat_rate_mmbtu_mwh") + + with op.batch_alter_table( + "_out_eia__yearly_heat_rate_by_unit", schema=None + ) as batch_op: + batch_op.add_column( + sa.Column( + "unit_heat_rate_mmbtu_per_mwh", + sa.Float(), + nullable=True, + comment="Fuel content per unit of electricity generated. Coming from MCOE calculation.", + ) + ) + batch_op.drop_column("heat_rate_mmbtu_mwh") + + with op.batch_alter_table("mega_generators_eia", schema=None) as batch_op: + batch_op.add_column( + sa.Column( + "unit_heat_rate_mmbtu_per_mwh", + sa.Float(), + nullable=True, + comment="Fuel content per unit of electricity generated. Coming from MCOE calculation.", + ) + ) + batch_op.drop_column("heat_rate_mmbtu_mwh") + + with op.batch_alter_table("out_eia__monthly_generators", schema=None) as batch_op: + batch_op.add_column( + sa.Column( + "unit_heat_rate_mmbtu_per_mwh", + sa.Float(), + nullable=True, + comment="Fuel content per unit of electricity generated. Coming from MCOE calculation.", + ) + ) + batch_op.drop_column("heat_rate_mmbtu_mwh") + + with op.batch_alter_table("out_eia__yearly_generators", schema=None) as batch_op: + batch_op.add_column( + sa.Column( + "unit_heat_rate_mmbtu_per_mwh", + sa.Float(), + nullable=True, + comment="Fuel content per unit of electricity generated. Coming from MCOE calculation.", + ) + ) + batch_op.drop_column("heat_rate_mmbtu_mwh") + + with op.batch_alter_table( + "out_eia__yearly_generators_by_ownership", schema=None + ) as batch_op: + batch_op.add_column( + sa.Column( + "unit_heat_rate_mmbtu_per_mwh", + sa.Float(), + nullable=True, + comment="Fuel content per unit of electricity generated. Coming from MCOE calculation.", + ) + ) + batch_op.drop_column("heat_rate_mmbtu_mwh") + + with op.batch_alter_table("out_eia__yearly_plant_parts", schema=None) as batch_op: + batch_op.add_column( + sa.Column( + "unit_heat_rate_mmbtu_per_mwh", + sa.Float(), + nullable=True, + comment="Fuel content per unit of electricity generated. Coming from MCOE calculation.", + ) + ) + batch_op.drop_column("heat_rate_mmbtu_mwh") + + with op.batch_alter_table( + "out_pudl__yearly_assn_eia_ferc1_plant_parts", schema=None + ) as batch_op: + batch_op.add_column( + sa.Column( + "unit_heat_rate_mmbtu_per_mwh_eia", + sa.Float(), + nullable=True, + comment="Fuel content per unit of electricity generated. Coming from MCOE calculation.", + ) + ) + batch_op.add_column( + sa.Column( + "unit_heat_rate_mmbtu_per_mwh_ferc1", + sa.Float(), + nullable=True, + comment="Fuel content per unit of electricity generated. Calculated from FERC reported fuel consumption and net generation.", + ) + ) + batch_op.drop_column("heat_rate_mmbtu_mwh_eia") + batch_op.drop_column("heat_rate_mmbtu_mwh_ferc1") + + with op.batch_alter_table("plant_parts_eia", schema=None) as batch_op: + batch_op.add_column( + sa.Column( + "unit_heat_rate_mmbtu_per_mwh", + sa.Float(), + nullable=True, + comment="Fuel content per unit of electricity generated. Coming from MCOE calculation.", + ) + ) + batch_op.drop_column("heat_rate_mmbtu_mwh") + + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table("plant_parts_eia", schema=None) as batch_op: + batch_op.add_column(sa.Column("heat_rate_mmbtu_mwh", sa.FLOAT(), nullable=True)) + batch_op.drop_column("unit_heat_rate_mmbtu_per_mwh") + + with op.batch_alter_table( + "out_pudl__yearly_assn_eia_ferc1_plant_parts", schema=None + ) as batch_op: + batch_op.add_column( + sa.Column("heat_rate_mmbtu_mwh_ferc1", sa.FLOAT(), nullable=True) + ) + batch_op.add_column( + sa.Column("heat_rate_mmbtu_mwh_eia", sa.FLOAT(), nullable=True) + ) + batch_op.drop_column("unit_heat_rate_mmbtu_per_mwh_ferc1") + batch_op.drop_column("unit_heat_rate_mmbtu_per_mwh_eia") + + with op.batch_alter_table("out_eia__yearly_plant_parts", schema=None) as batch_op: + batch_op.add_column(sa.Column("heat_rate_mmbtu_mwh", sa.FLOAT(), nullable=True)) + batch_op.drop_column("unit_heat_rate_mmbtu_per_mwh") + + with op.batch_alter_table( + "out_eia__yearly_generators_by_ownership", schema=None + ) as batch_op: + batch_op.add_column(sa.Column("heat_rate_mmbtu_mwh", sa.FLOAT(), nullable=True)) + batch_op.drop_column("unit_heat_rate_mmbtu_per_mwh") + + with op.batch_alter_table("out_eia__yearly_generators", schema=None) as batch_op: + batch_op.add_column(sa.Column("heat_rate_mmbtu_mwh", sa.FLOAT(), nullable=True)) + batch_op.drop_column("unit_heat_rate_mmbtu_per_mwh") + + with op.batch_alter_table("out_eia__monthly_generators", schema=None) as batch_op: + batch_op.add_column(sa.Column("heat_rate_mmbtu_mwh", sa.FLOAT(), nullable=True)) + batch_op.drop_column("unit_heat_rate_mmbtu_per_mwh") + + with op.batch_alter_table("mega_generators_eia", schema=None) as batch_op: + batch_op.add_column(sa.Column("heat_rate_mmbtu_mwh", sa.FLOAT(), nullable=True)) + batch_op.drop_column("unit_heat_rate_mmbtu_per_mwh") + + with op.batch_alter_table( + "_out_eia__yearly_heat_rate_by_unit", schema=None + ) as batch_op: + batch_op.add_column(sa.Column("heat_rate_mmbtu_mwh", sa.FLOAT(), nullable=True)) + batch_op.drop_column("unit_heat_rate_mmbtu_per_mwh") + + with op.batch_alter_table( + "_out_eia__yearly_heat_rate_by_generator", schema=None + ) as batch_op: + batch_op.add_column(sa.Column("heat_rate_mmbtu_mwh", sa.FLOAT(), nullable=True)) + batch_op.drop_column("unit_heat_rate_mmbtu_per_mwh") + + with op.batch_alter_table( + "_out_eia__yearly_fuel_cost_by_generator", schema=None + ) as batch_op: + batch_op.add_column(sa.Column("heat_rate_mmbtu_mwh", sa.FLOAT(), nullable=True)) + batch_op.drop_column("unit_heat_rate_mmbtu_per_mwh") + + with op.batch_alter_table( + "_out_eia__yearly_derived_generator_attributes", schema=None + ) as batch_op: + batch_op.add_column(sa.Column("heat_rate_mmbtu_mwh", sa.FLOAT(), nullable=True)) + batch_op.drop_column("unit_heat_rate_mmbtu_per_mwh") + + with op.batch_alter_table( + "_out_eia__monthly_heat_rate_by_unit", schema=None + ) as batch_op: + batch_op.add_column(sa.Column("heat_rate_mmbtu_mwh", sa.FLOAT(), nullable=True)) + batch_op.drop_column("unit_heat_rate_mmbtu_per_mwh") + + with op.batch_alter_table( + "_out_eia__monthly_heat_rate_by_generator", schema=None + ) as batch_op: + batch_op.add_column(sa.Column("heat_rate_mmbtu_mwh", sa.FLOAT(), nullable=True)) + batch_op.drop_column("unit_heat_rate_mmbtu_per_mwh") + + with op.batch_alter_table( + "_out_eia__monthly_fuel_cost_by_generator", schema=None + ) as batch_op: + batch_op.add_column(sa.Column("heat_rate_mmbtu_mwh", sa.FLOAT(), nullable=True)) + batch_op.drop_column("unit_heat_rate_mmbtu_per_mwh") + + with op.batch_alter_table( + "_out_eia__monthly_derived_generator_attributes", schema=None + ) as batch_op: + batch_op.add_column(sa.Column("heat_rate_mmbtu_mwh", sa.FLOAT(), nullable=True)) + batch_op.drop_column("unit_heat_rate_mmbtu_per_mwh") + + # ### end Alembic commands ###