diff --git a/migrations/versions/c73882df0765_rename_eia_denorm_assets.py b/migrations/versions/b3eb1a80721c_rename_eia_output_assets.py similarity index 99% rename from migrations/versions/c73882df0765_rename_eia_denorm_assets.py rename to migrations/versions/b3eb1a80721c_rename_eia_output_assets.py index 5653302de1..748fb94115 100644 --- a/migrations/versions/c73882df0765_rename_eia_denorm_assets.py +++ b/migrations/versions/b3eb1a80721c_rename_eia_output_assets.py @@ -1,16 +1,16 @@ -"""Rename eia denorm assets +"""Rename EIA output assets -Revision ID: c73882df0765 -Revises: 2ba971d7e675 -Create Date: 2023-09-15 13:11:05.940269 +Revision ID: b3eb1a80721c +Revises: 1c2c961a7be5 +Create Date: 2023-09-18 17:00:45.296107 """ import sqlalchemy as sa from alembic import op # revision identifiers, used by Alembic. -revision = 'c73882df0765' -down_revision = '2ba971d7e675' +revision = 'b3eb1a80721c' +down_revision = '1c2c961a7be5' branch_labels = None depends_on = None @@ -437,7 +437,7 @@ def upgrade() -> None: sa.Column('generator_id', sa.Text(), nullable=False, comment='Generator ID is usually numeric, but sometimes includes letters. Make sure you treat it as a string!'), sa.Column('owner_utility_id_eia', sa.Integer(), nullable=False, comment="EIA-assigned owner's identification number."), sa.Column('owner_name', sa.Text(), nullable=True, comment='Name of owner.'), - sa.Column('owner_state', sa.Enum('DC', 'OH', 'OK', 'KS', 'NB', 'PR', 'VA', 'SD', 'GA', 'WV', 'ND', 'GU', 'IL', 'TN', 'NT', 'CT', 'VI', 'ID', 'QC', 'NU', 'AK', 'MI', 'MT', 'NH', 'ON', 'AZ', 'MS', 'OR', 'AS', 'CO', 'ME', 'NC', 'MD', 'NY', 'AB', 'YT', 'KY', 'SK', 'DE', 'NV', 'NM', 'AL', 'NS', 'WY', 'WA', 'WI', 'NJ', 'SC', 'LA', 'MO', 'CA', 'BC', 'HI', 'MP', 'NE', 'NL', 'PA', 'MB', 'PE', 'IN', 'IA', 'UT', 'TX', 'VT', 'AR', 'MA', 'RI', 'MN', 'FL'), nullable=True, comment='Two letter ISO-3166 political subdivision code.'), + sa.Column('owner_state', sa.Enum('MB', 'NB', 'MD', 'OH', 'NH', 'AB', 'NS', 'OR', 'AL', 'MI', 'FL', 'SD', 'WY', 'YT', 'NJ', 'VA', 'IN', 'WV', 'VT', 'AK', 'MN', 'CT', 'AZ', 'ND', 'TN', 'SK', 'PR', 'OK', 'NV', 'TX', 'IA', 'NM', 'AS', 'NL', 'CA', 'KS', 'GU', 'KY', 'DE', 'CO', 'MO', 'BC', 'IL', 'MP', 'MS', 'PE', 'NY', 'RI', 'WI', 'ON', 'LA', 'HI', 'ME', 'DC', 'NE', 'NC', 'PA', 'GA', 'VI', 'MT', 'QC', 'WA', 'MA', 'AR', 'SC', 'NU', 'NT', 'ID', 'UT'), nullable=True, comment='Two letter ISO-3166 political subdivision code.'), sa.Column('owner_city', sa.Text(), nullable=True, comment='City of owner.'), sa.Column('owner_country', sa.Enum('USA', 'CAN'), nullable=True, comment='Three letter ISO-3166 country code.'), sa.Column('owner_street_address', sa.Text(), nullable=True, comment='Steet address of owner.'), @@ -789,82 +789,45 @@ def upgrade() -> None: sa.ForeignKeyConstraint(['utility_id_pudl'], ['core_pudl__entity_utilities_pudl.utility_id_pudl'], name=op.f('fk_out_eia__yearly_generators_utility_id_pudl_core_pudl__entity_utilities_pudl')), sa.PrimaryKeyConstraint('plant_id_eia', 'generator_id', 'report_date', name=op.f('pk_out_eia__yearly_generators')) ) - op.drop_table('denorm_generation_monthly_eia923') - op.drop_table('denorm_fuel_receipts_costs_eia923') - op.drop_table('denorm_plants_utilities_eia') + op.drop_table('denorm_boiler_fuel_yearly_eia923') + op.drop_table('denorm_generation_fuel_combined_monthly_eia923') + op.drop_table('denorm_plants_eia') op.drop_table('denorm_boiler_fuel_eia923') - op.drop_table('denorm_emissions_control_equipment_eia860') - op.drop_table('denorm_generation_fuel_combined_yearly_eia923') + op.drop_table('denorm_ownership_eia860') + op.drop_table('denorm_fuel_receipts_costs_monthly_eia923') + op.drop_table('denorm_boiler_fuel_monthly_eia923') op.drop_table('denorm_generation_yearly_eia923') - op.drop_table('denorm_utilities_eia') op.drop_table('denorm_generators_eia') + op.drop_table('denorm_generation_monthly_eia923') op.drop_table('denorm_generation_eia923') - op.drop_table('denorm_generation_fuel_combined_eia923') - op.drop_table('denorm_plants_eia') + op.drop_table('denorm_utilities_eia') + op.drop_table('denorm_fuel_receipts_costs_eia923') + op.drop_table('denorm_emissions_control_equipment_eia860') op.drop_table('denorm_boilers_eia') - op.drop_table('denorm_generation_fuel_combined_monthly_eia923') - op.drop_table('denorm_boiler_fuel_monthly_eia923') + op.drop_table('denorm_generation_fuel_combined_eia923') op.drop_table('denorm_fuel_receipts_costs_yearly_eia923') - op.drop_table('denorm_boiler_fuel_yearly_eia923') - op.drop_table('denorm_fuel_receipts_costs_monthly_eia923') - op.drop_table('denorm_ownership_eia860') + op.drop_table('denorm_generation_fuel_combined_yearly_eia923') + op.drop_table('denorm_plants_utilities_eia') # ### end Alembic commands ### def downgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### - op.create_table('denorm_ownership_eia860', + op.create_table('denorm_plants_utilities_eia', sa.Column('report_date', sa.DATE(), nullable=False), sa.Column('plant_id_eia', sa.INTEGER(), nullable=False), - sa.Column('plant_id_pudl', sa.INTEGER(), nullable=True), sa.Column('plant_name_eia', sa.TEXT(), nullable=True), - sa.Column('utility_id_eia', sa.INTEGER(), nullable=True), - sa.Column('utility_id_pudl', sa.INTEGER(), nullable=True), - sa.Column('utility_name_eia', sa.TEXT(), nullable=True), - sa.Column('generator_id', sa.TEXT(), nullable=False), - sa.Column('owner_utility_id_eia', sa.INTEGER(), nullable=False), - sa.Column('owner_name', sa.TEXT(), nullable=True), - sa.Column('owner_state', sa.VARCHAR(length=2), nullable=True), - sa.Column('owner_city', sa.TEXT(), nullable=True), - sa.Column('owner_country', sa.VARCHAR(length=3), nullable=True), - sa.Column('owner_street_address', sa.TEXT(), nullable=True), - sa.Column('owner_zip_code', sa.TEXT(), nullable=True), - sa.Column('fraction_owned', sa.FLOAT(), nullable=True), - sa.Column('data_maturity', sa.TEXT(), nullable=True), - sa.ForeignKeyConstraint(['data_maturity'], ['core_pudl__codes_data_maturities.code'], name='fk_denorm_ownership_eia860_data_maturity_core_pudl__codes_data_maturities'), - sa.ForeignKeyConstraint(['plant_id_eia', 'generator_id', 'report_date'], ['core_eia860__scd_generators.plant_id_eia', 'core_eia860__scd_generators.generator_id', 'core_eia860__scd_generators.report_date'], name='fk_denorm_ownership_eia860_plant_id_eia_core_eia860__scd_generators'), - sa.ForeignKeyConstraint(['plant_id_pudl'], ['core_pudl__entity_plants_pudl.plant_id_pudl'], name='fk_denorm_ownership_eia860_plant_id_pudl_core_pudl__entity_plants_pudl'), - sa.ForeignKeyConstraint(['utility_id_eia', 'report_date'], ['core_eia860__scd_utilities.utility_id_eia', 'core_eia860__scd_utilities.report_date'], name='fk_denorm_ownership_eia860_utility_id_eia_core_eia860__scd_utilities'), - sa.ForeignKeyConstraint(['utility_id_pudl'], ['core_pudl__entity_utilities_pudl.utility_id_pudl'], name='fk_denorm_ownership_eia860_utility_id_pudl_core_pudl__entity_utilities_pudl'), - sa.PrimaryKeyConstraint('report_date', 'plant_id_eia', 'generator_id', 'owner_utility_id_eia', name='pk_denorm_ownership_eia860') - ) - op.create_table('denorm_fuel_receipts_costs_monthly_eia923', - sa.Column('report_date', sa.DATE(), nullable=True), - sa.Column('plant_id_eia', sa.INTEGER(), nullable=True), sa.Column('plant_id_pudl', sa.INTEGER(), nullable=True), - sa.Column('plant_name_eia', sa.TEXT(), nullable=True), - sa.Column('utility_id_eia', sa.INTEGER(), nullable=True), - sa.Column('utility_id_pudl', sa.INTEGER(), nullable=True), + sa.Column('utility_id_eia', sa.INTEGER(), nullable=False), sa.Column('utility_name_eia', sa.TEXT(), nullable=True), - sa.Column('state', sa.TEXT(), nullable=True), - sa.Column('fuel_type_code_pudl', sa.VARCHAR(length=7), nullable=True), - sa.Column('fuel_received_units', sa.FLOAT(), nullable=True), - sa.Column('fuel_mmbtu_per_unit', sa.FLOAT(), nullable=True), - sa.Column('fuel_cost_per_mmbtu', sa.FLOAT(), nullable=True), - sa.Column('fuel_consumed_mmbtu', sa.FLOAT(), nullable=True), - sa.Column('total_fuel_cost', sa.FLOAT(), nullable=True), - sa.Column('fuel_cost_from_eiaapi', sa.BOOLEAN(), nullable=True), - sa.Column('sulfur_content_pct', sa.FLOAT(), nullable=True), - sa.Column('ash_content_pct', sa.FLOAT(), nullable=True), - sa.Column('mercury_content_ppm', sa.FLOAT(), nullable=True), - sa.Column('moisture_content_pct', sa.FLOAT(), nullable=True), - sa.Column('chlorine_content_ppm', sa.FLOAT(), nullable=True), - sa.ForeignKeyConstraint(['plant_id_eia'], ['core_eia__entity_plants.plant_id_eia'], name='fk_denorm_fuel_receipts_costs_monthly_eia923_plant_id_eia_core_eia__entity_plants'), - sa.ForeignKeyConstraint(['plant_id_pudl'], ['core_pudl__entity_plants_pudl.plant_id_pudl'], name='fk_denorm_fuel_receipts_costs_monthly_eia923_plant_id_pudl_core_pudl__entity_plants_pudl'), - sa.ForeignKeyConstraint(['utility_id_eia'], ['core_eia__entity_utilities.utility_id_eia'], name='fk_denorm_fuel_receipts_costs_monthly_eia923_utility_id_eia_core_eia__entity_utilities'), - sa.ForeignKeyConstraint(['utility_id_pudl'], ['core_pudl__entity_utilities_pudl.utility_id_pudl'], name='fk_denorm_fuel_receipts_costs_monthly_eia923_utility_id_pudl_core_pudl__entity_utilities_pudl') + sa.Column('utility_id_pudl', sa.INTEGER(), nullable=True), + sa.ForeignKeyConstraint(['plant_id_eia', 'report_date'], ['core_eia860__scd_plants.plant_id_eia', 'core_eia860__scd_plants.report_date'], name='fk_denorm_plants_utilities_eia_plant_id_eia_core_eia860__scd_plants'), + sa.ForeignKeyConstraint(['plant_id_pudl'], ['core_pudl__entity_plants_pudl.plant_id_pudl'], name='fk_denorm_plants_utilities_eia_plant_id_pudl_core_pudl__entity_plants_pudl'), + sa.ForeignKeyConstraint(['utility_id_eia', 'report_date'], ['core_eia860__scd_utilities.utility_id_eia', 'core_eia860__scd_utilities.report_date'], name='fk_denorm_plants_utilities_eia_utility_id_eia_core_eia860__scd_utilities'), + sa.ForeignKeyConstraint(['utility_id_pudl'], ['core_pudl__entity_utilities_pudl.utility_id_pudl'], name='fk_denorm_plants_utilities_eia_utility_id_pudl_core_pudl__entity_utilities_pudl'), + sa.PrimaryKeyConstraint('report_date', 'plant_id_eia', 'utility_id_eia', name='pk_denorm_plants_utilities_eia') ) - op.create_table('denorm_boiler_fuel_yearly_eia923', + op.create_table('denorm_generation_fuel_combined_yearly_eia923', sa.Column('report_date', sa.DATE(), nullable=False), sa.Column('plant_id_eia', sa.INTEGER(), nullable=False), sa.Column('plant_id_pudl', sa.INTEGER(), nullable=True), @@ -872,23 +835,22 @@ def downgrade() -> None: sa.Column('utility_id_eia', sa.INTEGER(), nullable=True), sa.Column('utility_id_pudl', sa.INTEGER(), nullable=True), sa.Column('utility_name_eia', sa.TEXT(), nullable=True), - sa.Column('boiler_id', sa.TEXT(), nullable=False), - sa.Column('unit_id_pudl', sa.INTEGER(), nullable=True), sa.Column('energy_source_code', sa.TEXT(), nullable=False), - sa.Column('prime_mover_code', sa.TEXT(), nullable=False), sa.Column('fuel_type_code_pudl', sa.VARCHAR(length=7), nullable=True), + sa.Column('prime_mover_code', sa.TEXT(), nullable=False), sa.Column('fuel_consumed_units', sa.FLOAT(), nullable=True), + sa.Column('fuel_consumed_for_electricity_units', sa.FLOAT(), nullable=True), sa.Column('fuel_mmbtu_per_unit', sa.FLOAT(), nullable=True), sa.Column('fuel_consumed_mmbtu', sa.FLOAT(), nullable=True), - sa.Column('sulfur_content_pct', sa.FLOAT(), nullable=True), - sa.Column('ash_content_pct', sa.FLOAT(), nullable=True), - sa.ForeignKeyConstraint(['energy_source_code'], ['core_eia__codes_energy_sources.code'], name='fk_denorm_boiler_fuel_yearly_eia923_energy_source_code_core_eia__codes_energy_sources'), - sa.ForeignKeyConstraint(['plant_id_eia', 'boiler_id', 'report_date'], ['core_eia860__scd_boilers.plant_id_eia', 'core_eia860__scd_boilers.boiler_id', 'core_eia860__scd_boilers.report_date'], name='fk_denorm_boiler_fuel_yearly_eia923_plant_id_eia_core_eia860__scd_boilers'), - sa.ForeignKeyConstraint(['plant_id_pudl'], ['core_pudl__entity_plants_pudl.plant_id_pudl'], name='fk_denorm_boiler_fuel_yearly_eia923_plant_id_pudl_core_pudl__entity_plants_pudl'), - sa.ForeignKeyConstraint(['prime_mover_code'], ['core_eia__codes_prime_movers.code'], name='fk_denorm_boiler_fuel_yearly_eia923_prime_mover_code_core_eia__codes_prime_movers'), - sa.ForeignKeyConstraint(['utility_id_eia', 'report_date'], ['core_eia860__scd_utilities.utility_id_eia', 'core_eia860__scd_utilities.report_date'], name='fk_denorm_boiler_fuel_yearly_eia923_utility_id_eia_core_eia860__scd_utilities'), - sa.ForeignKeyConstraint(['utility_id_pudl'], ['core_pudl__entity_utilities_pudl.utility_id_pudl'], name='fk_denorm_boiler_fuel_yearly_eia923_utility_id_pudl_core_pudl__entity_utilities_pudl'), - sa.PrimaryKeyConstraint('plant_id_eia', 'boiler_id', 'energy_source_code', 'prime_mover_code', 'report_date', name='pk_denorm_boiler_fuel_yearly_eia923') + sa.Column('fuel_consumed_for_electricity_mmbtu', sa.FLOAT(), nullable=True), + sa.Column('net_generation_mwh', sa.FLOAT(), nullable=True), + sa.ForeignKeyConstraint(['energy_source_code'], ['core_eia__codes_energy_sources.code'], name='fk_denorm_generation_fuel_combined_yearly_eia923_energy_source_code_core_eia__codes_energy_sources'), + sa.ForeignKeyConstraint(['plant_id_eia', 'report_date'], ['core_eia860__scd_plants.plant_id_eia', 'core_eia860__scd_plants.report_date'], name='fk_denorm_generation_fuel_combined_yearly_eia923_plant_id_eia_core_eia860__scd_plants'), + sa.ForeignKeyConstraint(['plant_id_pudl'], ['core_pudl__entity_plants_pudl.plant_id_pudl'], name='fk_denorm_generation_fuel_combined_yearly_eia923_plant_id_pudl_core_pudl__entity_plants_pudl'), + sa.ForeignKeyConstraint(['prime_mover_code'], ['core_eia__codes_prime_movers.code'], name='fk_denorm_generation_fuel_combined_yearly_eia923_prime_mover_code_core_eia__codes_prime_movers'), + sa.ForeignKeyConstraint(['utility_id_eia', 'report_date'], ['core_eia860__scd_utilities.utility_id_eia', 'core_eia860__scd_utilities.report_date'], name='fk_denorm_generation_fuel_combined_yearly_eia923_utility_id_eia_core_eia860__scd_utilities'), + sa.ForeignKeyConstraint(['utility_id_pudl'], ['core_pudl__entity_utilities_pudl.utility_id_pudl'], name='fk_denorm_generation_fuel_combined_yearly_eia923_utility_id_pudl_core_pudl__entity_utilities_pudl'), + sa.PrimaryKeyConstraint('plant_id_eia', 'report_date', 'prime_mover_code', 'energy_source_code', name='pk_denorm_generation_fuel_combined_yearly_eia923') ) op.create_table('denorm_fuel_receipts_costs_yearly_eia923', sa.Column('report_date', sa.DATE(), nullable=True), @@ -916,33 +878,7 @@ def downgrade() -> None: sa.ForeignKeyConstraint(['utility_id_eia', 'report_date'], ['core_eia860__scd_utilities.utility_id_eia', 'core_eia860__scd_utilities.report_date'], name='fk_denorm_fuel_receipts_costs_yearly_eia923_utility_id_eia_core_eia860__scd_utilities'), sa.ForeignKeyConstraint(['utility_id_pudl'], ['core_pudl__entity_utilities_pudl.utility_id_pudl'], name='fk_denorm_fuel_receipts_costs_yearly_eia923_utility_id_pudl_core_pudl__entity_utilities_pudl') ) - op.create_table('denorm_boiler_fuel_monthly_eia923', - sa.Column('report_date', sa.DATE(), nullable=False), - sa.Column('plant_id_eia', sa.INTEGER(), nullable=False), - sa.Column('plant_id_pudl', sa.INTEGER(), nullable=True), - sa.Column('plant_name_eia', sa.TEXT(), nullable=True), - sa.Column('utility_id_eia', sa.INTEGER(), nullable=True), - sa.Column('utility_id_pudl', sa.INTEGER(), nullable=True), - sa.Column('utility_name_eia', sa.TEXT(), nullable=True), - sa.Column('boiler_id', sa.TEXT(), nullable=False), - sa.Column('unit_id_pudl', sa.INTEGER(), nullable=True), - sa.Column('energy_source_code', sa.TEXT(), nullable=False), - sa.Column('prime_mover_code', sa.TEXT(), nullable=False), - sa.Column('fuel_type_code_pudl', sa.VARCHAR(length=7), nullable=True), - sa.Column('fuel_consumed_units', sa.FLOAT(), nullable=True), - sa.Column('fuel_mmbtu_per_unit', sa.FLOAT(), nullable=True), - sa.Column('fuel_consumed_mmbtu', sa.FLOAT(), nullable=True), - sa.Column('sulfur_content_pct', sa.FLOAT(), nullable=True), - sa.Column('ash_content_pct', sa.FLOAT(), nullable=True), - sa.ForeignKeyConstraint(['energy_source_code'], ['core_eia__codes_energy_sources.code'], name='fk_denorm_boiler_fuel_monthly_eia923_energy_source_code_core_eia__codes_energy_sources'), - sa.ForeignKeyConstraint(['plant_id_eia', 'boiler_id'], ['core_eia__entity_boilers.plant_id_eia', 'core_eia__entity_boilers.boiler_id'], name='fk_denorm_boiler_fuel_monthly_eia923_plant_id_eia_core_eia__entity_boilers'), - sa.ForeignKeyConstraint(['plant_id_pudl'], ['core_pudl__entity_plants_pudl.plant_id_pudl'], name='fk_denorm_boiler_fuel_monthly_eia923_plant_id_pudl_core_pudl__entity_plants_pudl'), - sa.ForeignKeyConstraint(['prime_mover_code'], ['core_eia__codes_prime_movers.code'], name='fk_denorm_boiler_fuel_monthly_eia923_prime_mover_code_core_eia__codes_prime_movers'), - sa.ForeignKeyConstraint(['utility_id_eia'], ['core_eia__entity_utilities.utility_id_eia'], name='fk_denorm_boiler_fuel_monthly_eia923_utility_id_eia_core_eia__entity_utilities'), - sa.ForeignKeyConstraint(['utility_id_pudl'], ['core_pudl__entity_utilities_pudl.utility_id_pudl'], name='fk_denorm_boiler_fuel_monthly_eia923_utility_id_pudl_core_pudl__entity_utilities_pudl'), - sa.PrimaryKeyConstraint('plant_id_eia', 'boiler_id', 'energy_source_code', 'prime_mover_code', 'report_date', name='pk_denorm_boiler_fuel_monthly_eia923') - ) - op.create_table('denorm_generation_fuel_combined_monthly_eia923', + op.create_table('denorm_generation_fuel_combined_eia923', sa.Column('report_date', sa.DATE(), nullable=False), sa.Column('plant_id_eia', sa.INTEGER(), nullable=False), sa.Column('plant_id_pudl', sa.INTEGER(), nullable=True), @@ -952,6 +888,7 @@ def downgrade() -> None: sa.Column('utility_name_eia', sa.TEXT(), nullable=True), sa.Column('energy_source_code', sa.TEXT(), nullable=False), sa.Column('fuel_type_code_pudl', sa.VARCHAR(length=7), nullable=True), + sa.Column('fuel_type_code_aer', sa.TEXT(), nullable=True), sa.Column('prime_mover_code', sa.TEXT(), nullable=False), sa.Column('fuel_consumed_units', sa.FLOAT(), nullable=True), sa.Column('fuel_consumed_for_electricity_units', sa.FLOAT(), nullable=True), @@ -959,13 +896,16 @@ def downgrade() -> None: sa.Column('fuel_consumed_mmbtu', sa.FLOAT(), nullable=True), sa.Column('fuel_consumed_for_electricity_mmbtu', sa.FLOAT(), nullable=True), sa.Column('net_generation_mwh', sa.FLOAT(), nullable=True), - sa.ForeignKeyConstraint(['energy_source_code'], ['core_eia__codes_energy_sources.code'], name='fk_denorm_generation_fuel_combined_monthly_eia923_energy_source_code_core_eia__codes_energy_sources'), - sa.ForeignKeyConstraint(['plant_id_eia'], ['core_eia__entity_plants.plant_id_eia'], name='fk_denorm_generation_fuel_combined_monthly_eia923_plant_id_eia_core_eia__entity_plants'), - sa.ForeignKeyConstraint(['plant_id_pudl'], ['core_pudl__entity_plants_pudl.plant_id_pudl'], name='fk_denorm_generation_fuel_combined_monthly_eia923_plant_id_pudl_core_pudl__entity_plants_pudl'), - sa.ForeignKeyConstraint(['prime_mover_code'], ['core_eia__codes_prime_movers.code'], name='fk_denorm_generation_fuel_combined_monthly_eia923_prime_mover_code_core_eia__codes_prime_movers'), - sa.ForeignKeyConstraint(['utility_id_eia'], ['core_eia__entity_utilities.utility_id_eia'], name='fk_denorm_generation_fuel_combined_monthly_eia923_utility_id_eia_core_eia__entity_utilities'), - sa.ForeignKeyConstraint(['utility_id_pudl'], ['core_pudl__entity_utilities_pudl.utility_id_pudl'], name='fk_denorm_generation_fuel_combined_monthly_eia923_utility_id_pudl_core_pudl__entity_utilities_pudl'), - sa.PrimaryKeyConstraint('plant_id_eia', 'report_date', 'prime_mover_code', 'energy_source_code', name='pk_denorm_generation_fuel_combined_monthly_eia923') + sa.Column('data_maturity', sa.TEXT(), nullable=True), + sa.ForeignKeyConstraint(['data_maturity'], ['core_pudl__codes_data_maturities.code'], name='fk_denorm_generation_fuel_combined_eia923_data_maturity_core_pudl__codes_data_maturities'), + sa.ForeignKeyConstraint(['energy_source_code'], ['core_eia__codes_energy_sources.code'], name='fk_denorm_generation_fuel_combined_eia923_energy_source_code_core_eia__codes_energy_sources'), + sa.ForeignKeyConstraint(['fuel_type_code_aer'], ['core_eia__codes_fuel_types_aer.code'], name='fk_denorm_generation_fuel_combined_eia923_fuel_type_code_aer_core_eia__codes_fuel_types_aer'), + sa.ForeignKeyConstraint(['plant_id_eia'], ['core_eia__entity_plants.plant_id_eia'], name='fk_denorm_generation_fuel_combined_eia923_plant_id_eia_core_eia__entity_plants'), + sa.ForeignKeyConstraint(['plant_id_pudl'], ['core_pudl__entity_plants_pudl.plant_id_pudl'], name='fk_denorm_generation_fuel_combined_eia923_plant_id_pudl_core_pudl__entity_plants_pudl'), + sa.ForeignKeyConstraint(['prime_mover_code'], ['core_eia__codes_prime_movers.code'], name='fk_denorm_generation_fuel_combined_eia923_prime_mover_code_core_eia__codes_prime_movers'), + sa.ForeignKeyConstraint(['utility_id_eia'], ['core_eia__entity_utilities.utility_id_eia'], name='fk_denorm_generation_fuel_combined_eia923_utility_id_eia_core_eia__entity_utilities'), + sa.ForeignKeyConstraint(['utility_id_pudl'], ['core_pudl__entity_utilities_pudl.utility_id_pudl'], name='fk_denorm_generation_fuel_combined_eia923_utility_id_pudl_core_pudl__entity_utilities_pudl'), + sa.PrimaryKeyConstraint('plant_id_eia', 'report_date', 'prime_mover_code', 'energy_source_code', name='pk_denorm_generation_fuel_combined_eia923') ) op.create_table('denorm_boilers_eia', sa.Column('report_date', sa.DATE(), nullable=False), @@ -1132,99 +1072,116 @@ def downgrade() -> None: sa.ForeignKeyConstraint(['wet_dry_bottom'], ['core_eia__codes_wet_dry_bottom.code'], name='fk_denorm_boilers_eia_wet_dry_bottom_core_eia__codes_wet_dry_bottom'), sa.PrimaryKeyConstraint('plant_id_eia', 'boiler_id', 'report_date', name='pk_denorm_boilers_eia') ) - op.create_table('denorm_plants_eia', + op.create_table('denorm_emissions_control_equipment_eia860', + sa.Column('report_year', sa.INTEGER(), nullable=False), sa.Column('plant_id_eia', sa.INTEGER(), nullable=False), + sa.Column('plant_id_pudl', sa.INTEGER(), nullable=True), sa.Column('plant_name_eia', sa.TEXT(), nullable=True), - sa.Column('city', sa.TEXT(), nullable=True), - sa.Column('county', sa.TEXT(), nullable=True), - sa.Column('latitude', sa.FLOAT(), nullable=True), - sa.Column('longitude', sa.FLOAT(), nullable=True), - sa.Column('state', sa.TEXT(), nullable=True), - sa.Column('street_address', sa.TEXT(), nullable=True), - sa.Column('zip_code', sa.TEXT(), nullable=True), - sa.Column('timezone', sa.VARCHAR(length=32), nullable=True), - sa.Column('report_date', sa.DATE(), nullable=False), - sa.Column('ash_impoundment', sa.BOOLEAN(), nullable=True), - sa.Column('ash_impoundment_lined', sa.BOOLEAN(), nullable=True), - sa.Column('ash_impoundment_status', sa.TEXT(), nullable=True), - sa.Column('balancing_authority_code_eia', sa.TEXT(), nullable=True), - sa.Column('balancing_authority_name_eia', sa.TEXT(), nullable=True), - sa.Column('datum', sa.TEXT(), nullable=True), - sa.Column('energy_storage', sa.BOOLEAN(), nullable=True), - sa.Column('ferc_cogen_docket_no', sa.TEXT(), nullable=True), - sa.Column('ferc_cogen_status', sa.BOOLEAN(), nullable=True), - sa.Column('ferc_exempt_wholesale_generator_docket_no', sa.TEXT(), nullable=True), - sa.Column('ferc_exempt_wholesale_generator', sa.BOOLEAN(), nullable=True), - sa.Column('ferc_small_power_producer_docket_no', sa.TEXT(), nullable=True), - sa.Column('ferc_small_power_producer', sa.BOOLEAN(), nullable=True), - sa.Column('ferc_qualifying_facility_docket_no', sa.TEXT(), nullable=True), - sa.Column('grid_voltage_1_kv', sa.FLOAT(), nullable=True), - sa.Column('grid_voltage_2_kv', sa.FLOAT(), nullable=True), - sa.Column('grid_voltage_3_kv', sa.FLOAT(), nullable=True), - sa.Column('iso_rto_code', sa.TEXT(), nullable=True), - sa.Column('liquefied_natural_gas_storage', sa.BOOLEAN(), nullable=True), - sa.Column('natural_gas_local_distribution_company', sa.TEXT(), nullable=True), - sa.Column('natural_gas_storage', sa.BOOLEAN(), nullable=True), - sa.Column('natural_gas_pipeline_name_1', sa.TEXT(), nullable=True), - sa.Column('natural_gas_pipeline_name_2', sa.TEXT(), nullable=True), - sa.Column('natural_gas_pipeline_name_3', sa.TEXT(), nullable=True), - sa.Column('nerc_region', sa.VARCHAR(length=9), nullable=True), - sa.Column('net_metering', sa.BOOLEAN(), nullable=True), - sa.Column('pipeline_notes', sa.TEXT(), nullable=True), - sa.Column('primary_purpose_id_naics', sa.INTEGER(), nullable=True), - sa.Column('regulatory_status_code', sa.TEXT(), nullable=True), - sa.Column('reporting_frequency_code', sa.VARCHAR(length=2), nullable=True), - sa.Column('sector_id_eia', sa.INTEGER(), nullable=True), - sa.Column('sector_name_eia', sa.TEXT(), nullable=True), - sa.Column('service_area', sa.TEXT(), nullable=True), - sa.Column('transmission_distribution_owner_id', sa.INTEGER(), nullable=True), - sa.Column('transmission_distribution_owner_name', sa.TEXT(), nullable=True), - sa.Column('transmission_distribution_owner_state', sa.TEXT(), nullable=True), sa.Column('utility_id_eia', sa.INTEGER(), nullable=True), - sa.Column('water_source', sa.TEXT(), nullable=True), - sa.Column('data_maturity', sa.TEXT(), nullable=True), - sa.Column('plant_id_pudl', sa.INTEGER(), nullable=True), - sa.Column('utility_name_eia', sa.TEXT(), nullable=True), sa.Column('utility_id_pudl', sa.INTEGER(), nullable=True), - sa.Column('balancing_authority_code_eia_consistent_rate', sa.FLOAT(), nullable=True), - sa.ForeignKeyConstraint(['balancing_authority_code_eia'], ['core_eia__codes_balancing_authorities.code'], name='fk_denorm_plants_eia_balancing_authority_code_eia_core_eia__codes_balancing_authorities'), - sa.ForeignKeyConstraint(['data_maturity'], ['core_pudl__codes_data_maturities.code'], name='fk_denorm_plants_eia_data_maturity_core_pudl__codes_data_maturities'), - sa.ForeignKeyConstraint(['plant_id_eia', 'report_date'], ['core_eia860__scd_plants.plant_id_eia', 'core_eia860__scd_plants.report_date'], name='fk_denorm_plants_eia_plant_id_eia_core_eia860__scd_plants'), - sa.ForeignKeyConstraint(['plant_id_pudl'], ['core_pudl__entity_plants_pudl.plant_id_pudl'], name='fk_denorm_plants_eia_plant_id_pudl_core_pudl__entity_plants_pudl'), - sa.ForeignKeyConstraint(['reporting_frequency_code'], ['core_eia__codes_reporting_frequencies.code'], name='fk_denorm_plants_eia_reporting_frequency_code_core_eia__codes_reporting_frequencies'), - sa.ForeignKeyConstraint(['sector_id_eia'], ['core_eia__codes_sector_consolidated.code'], name='fk_denorm_plants_eia_sector_id_eia_core_eia__codes_sector_consolidated'), - sa.ForeignKeyConstraint(['utility_id_eia', 'report_date'], ['core_eia860__scd_utilities.utility_id_eia', 'core_eia860__scd_utilities.report_date'], name='fk_denorm_plants_eia_utility_id_eia_core_eia860__scd_utilities'), - sa.ForeignKeyConstraint(['utility_id_pudl'], ['core_pudl__entity_utilities_pudl.utility_id_pudl'], name='fk_denorm_plants_eia_utility_id_pudl_core_pudl__entity_utilities_pudl'), - sa.PrimaryKeyConstraint('plant_id_eia', 'report_date', name='pk_denorm_plants_eia') + sa.Column('utility_name_eia', sa.TEXT(), nullable=True), + sa.Column('emission_control_id_pudl', sa.FLOAT(), nullable=False), + sa.Column('data_maturity', sa.TEXT(), nullable=True), + sa.Column('emission_control_equipment_type_code', sa.TEXT(), nullable=True), + sa.Column('operational_status_code', sa.TEXT(), nullable=True), + sa.Column('operational_status', sa.TEXT(), nullable=True), + sa.Column('mercury_control_id_eia', sa.TEXT(), nullable=True), + sa.Column('nox_control_id_eia', sa.TEXT(), nullable=True), + sa.Column('particulate_control_id_eia', sa.TEXT(), nullable=True), + sa.Column('so2_control_id_eia', sa.TEXT(), nullable=True), + sa.Column('acid_gas_control', sa.BOOLEAN(), nullable=True), + sa.Column('emission_control_equipment_cost', sa.FLOAT(), nullable=True), + sa.Column('emission_control_operating_date', sa.DATE(), nullable=True), + sa.Column('emission_control_retirement_date', sa.DATE(), nullable=True), + sa.ForeignKeyConstraint(['data_maturity'], ['core_pudl__codes_data_maturities.code'], name='fk_denorm_emissions_control_equipment_eia860_data_maturity_core_pudl__codes_data_maturities'), + sa.ForeignKeyConstraint(['emission_control_equipment_type_code'], ['core_eia__codes_emission_control_equipment_types.code'], name='fk_denorm_emissions_control_equipment_eia860_emission_control_equipment_type_code_core_eia__codes_emission_control_equipment_types'), + sa.ForeignKeyConstraint(['operational_status_code'], ['core_eia__codes_operational_status.code'], name='fk_denorm_emissions_control_equipment_eia860_operational_status_code_core_eia__codes_operational_status'), + sa.ForeignKeyConstraint(['plant_id_eia'], ['core_eia__entity_plants.plant_id_eia'], name='fk_denorm_emissions_control_equipment_eia860_plant_id_eia_core_eia__entity_plants'), + sa.ForeignKeyConstraint(['plant_id_pudl'], ['core_pudl__entity_plants_pudl.plant_id_pudl'], name='fk_denorm_emissions_control_equipment_eia860_plant_id_pudl_core_pudl__entity_plants_pudl'), + sa.ForeignKeyConstraint(['utility_id_eia'], ['core_eia__entity_utilities.utility_id_eia'], name='fk_denorm_emissions_control_equipment_eia860_utility_id_eia_core_eia__entity_utilities'), + sa.ForeignKeyConstraint(['utility_id_pudl'], ['core_pudl__entity_utilities_pudl.utility_id_pudl'], name='fk_denorm_emissions_control_equipment_eia860_utility_id_pudl_core_pudl__entity_utilities_pudl'), + sa.PrimaryKeyConstraint('report_year', 'plant_id_eia', 'emission_control_id_pudl', name='pk_denorm_emissions_control_equipment_eia860') ) - op.create_table('denorm_generation_fuel_combined_eia923', - sa.Column('report_date', sa.DATE(), nullable=False), - sa.Column('plant_id_eia', sa.INTEGER(), nullable=False), + op.create_table('denorm_fuel_receipts_costs_eia923', + sa.Column('report_date', sa.DATE(), nullable=True), + sa.Column('plant_id_eia', sa.INTEGER(), nullable=True), sa.Column('plant_id_pudl', sa.INTEGER(), nullable=True), sa.Column('plant_name_eia', sa.TEXT(), nullable=True), sa.Column('utility_id_eia', sa.INTEGER(), nullable=True), sa.Column('utility_id_pudl', sa.INTEGER(), nullable=True), sa.Column('utility_name_eia', sa.TEXT(), nullable=True), - sa.Column('energy_source_code', sa.TEXT(), nullable=False), + sa.Column('state', sa.TEXT(), nullable=True), + sa.Column('contract_type_code', sa.VARCHAR(length=2), nullable=True), + sa.Column('contract_expiration_date', sa.DATE(), nullable=True), + sa.Column('energy_source_code', sa.TEXT(), nullable=True), sa.Column('fuel_type_code_pudl', sa.VARCHAR(length=7), nullable=True), - sa.Column('fuel_type_code_aer', sa.TEXT(), nullable=True), - sa.Column('prime_mover_code', sa.TEXT(), nullable=False), - sa.Column('fuel_consumed_units', sa.FLOAT(), nullable=True), - sa.Column('fuel_consumed_for_electricity_units', sa.FLOAT(), nullable=True), + sa.Column('fuel_group_code', sa.VARCHAR(length=14), nullable=True), + sa.Column('supplier_name', sa.TEXT(), nullable=True), + sa.Column('fuel_received_units', sa.FLOAT(), nullable=True), sa.Column('fuel_mmbtu_per_unit', sa.FLOAT(), nullable=True), + sa.Column('fuel_cost_per_mmbtu', sa.FLOAT(), nullable=True), + sa.Column('bulk_agg_fuel_cost_per_mmbtu', sa.FLOAT(), nullable=True), sa.Column('fuel_consumed_mmbtu', sa.FLOAT(), nullable=True), - sa.Column('fuel_consumed_for_electricity_mmbtu', sa.FLOAT(), nullable=True), - sa.Column('net_generation_mwh', sa.FLOAT(), nullable=True), + sa.Column('total_fuel_cost', sa.FLOAT(), nullable=True), + sa.Column('fuel_cost_from_eiaapi', sa.BOOLEAN(), nullable=True), + sa.Column('sulfur_content_pct', sa.FLOAT(), nullable=True), + sa.Column('ash_content_pct', sa.FLOAT(), nullable=True), + sa.Column('mercury_content_ppm', sa.FLOAT(), nullable=True), + sa.Column('primary_transportation_mode_code', sa.TEXT(), nullable=True), + sa.Column('secondary_transportation_mode_code', sa.TEXT(), nullable=True), + sa.Column('natural_gas_transport_code', sa.VARCHAR(length=13), nullable=True), + sa.Column('natural_gas_delivery_contract_type_code', sa.VARCHAR(length=13), nullable=True), + sa.Column('moisture_content_pct', sa.FLOAT(), nullable=True), + sa.Column('chlorine_content_ppm', sa.FLOAT(), nullable=True), sa.Column('data_maturity', sa.TEXT(), nullable=True), - sa.ForeignKeyConstraint(['data_maturity'], ['core_pudl__codes_data_maturities.code'], name='fk_denorm_generation_fuel_combined_eia923_data_maturity_core_pudl__codes_data_maturities'), - sa.ForeignKeyConstraint(['energy_source_code'], ['core_eia__codes_energy_sources.code'], name='fk_denorm_generation_fuel_combined_eia923_energy_source_code_core_eia__codes_energy_sources'), - sa.ForeignKeyConstraint(['fuel_type_code_aer'], ['core_eia__codes_fuel_types_aer.code'], name='fk_denorm_generation_fuel_combined_eia923_fuel_type_code_aer_core_eia__codes_fuel_types_aer'), - sa.ForeignKeyConstraint(['plant_id_eia'], ['core_eia__entity_plants.plant_id_eia'], name='fk_denorm_generation_fuel_combined_eia923_plant_id_eia_core_eia__entity_plants'), - sa.ForeignKeyConstraint(['plant_id_pudl'], ['core_pudl__entity_plants_pudl.plant_id_pudl'], name='fk_denorm_generation_fuel_combined_eia923_plant_id_pudl_core_pudl__entity_plants_pudl'), - sa.ForeignKeyConstraint(['prime_mover_code'], ['core_eia__codes_prime_movers.code'], name='fk_denorm_generation_fuel_combined_eia923_prime_mover_code_core_eia__codes_prime_movers'), - sa.ForeignKeyConstraint(['utility_id_eia'], ['core_eia__entity_utilities.utility_id_eia'], name='fk_denorm_generation_fuel_combined_eia923_utility_id_eia_core_eia__entity_utilities'), - sa.ForeignKeyConstraint(['utility_id_pudl'], ['core_pudl__entity_utilities_pudl.utility_id_pudl'], name='fk_denorm_generation_fuel_combined_eia923_utility_id_pudl_core_pudl__entity_utilities_pudl'), - sa.PrimaryKeyConstraint('plant_id_eia', 'report_date', 'prime_mover_code', 'energy_source_code', name='pk_denorm_generation_fuel_combined_eia923') + sa.Column('mine_id_msha', sa.INTEGER(), nullable=True), + sa.Column('mine_name', sa.TEXT(), nullable=True), + sa.Column('mine_state', sa.TEXT(), nullable=True), + sa.Column('coalmine_county_id_fips', sa.TEXT(), nullable=True), + sa.Column('mine_type_code', sa.TEXT(), nullable=True), + sa.ForeignKeyConstraint(['contract_type_code'], ['core_eia__codes_contract_types.code'], name='fk_denorm_fuel_receipts_costs_eia923_contract_type_code_core_eia__codes_contract_types'), + sa.ForeignKeyConstraint(['data_maturity'], ['core_pudl__codes_data_maturities.code'], name='fk_denorm_fuel_receipts_costs_eia923_data_maturity_core_pudl__codes_data_maturities'), + sa.ForeignKeyConstraint(['energy_source_code'], ['core_eia__codes_energy_sources.code'], name='fk_denorm_fuel_receipts_costs_eia923_energy_source_code_core_eia__codes_energy_sources'), + sa.ForeignKeyConstraint(['mine_type_code'], ['core_eia__codes_coalmine_types.code'], name='fk_denorm_fuel_receipts_costs_eia923_mine_type_code_core_eia__codes_coalmine_types'), + sa.ForeignKeyConstraint(['plant_id_eia'], ['core_eia__entity_plants.plant_id_eia'], name='fk_denorm_fuel_receipts_costs_eia923_plant_id_eia_core_eia__entity_plants'), + sa.ForeignKeyConstraint(['plant_id_pudl'], ['core_pudl__entity_plants_pudl.plant_id_pudl'], name='fk_denorm_fuel_receipts_costs_eia923_plant_id_pudl_core_pudl__entity_plants_pudl'), + sa.ForeignKeyConstraint(['primary_transportation_mode_code'], ['core_eia__codes_fuel_transportation_modes.code'], name='fk_denorm_fuel_receipts_costs_eia923_primary_transportation_mode_code_core_eia__codes_fuel_transportation_modes'), + sa.ForeignKeyConstraint(['secondary_transportation_mode_code'], ['core_eia__codes_fuel_transportation_modes.code'], name='fk_denorm_fuel_receipts_costs_eia923_secondary_transportation_mode_code_core_eia__codes_fuel_transportation_modes'), + sa.ForeignKeyConstraint(['utility_id_eia'], ['core_eia__entity_utilities.utility_id_eia'], name='fk_denorm_fuel_receipts_costs_eia923_utility_id_eia_core_eia__entity_utilities'), + sa.ForeignKeyConstraint(['utility_id_pudl'], ['core_pudl__entity_utilities_pudl.utility_id_pudl'], name='fk_denorm_fuel_receipts_costs_eia923_utility_id_pudl_core_pudl__entity_utilities_pudl') + ) + op.create_table('denorm_utilities_eia', + sa.Column('utility_id_eia', sa.INTEGER(), nullable=False), + sa.Column('utility_id_pudl', sa.INTEGER(), nullable=True), + sa.Column('utility_name_eia', sa.TEXT(), nullable=True), + sa.Column('report_date', sa.DATE(), nullable=False), + sa.Column('street_address', sa.TEXT(), nullable=True), + sa.Column('city', sa.TEXT(), nullable=True), + sa.Column('state', sa.TEXT(), nullable=True), + sa.Column('zip_code', sa.TEXT(), nullable=True), + sa.Column('plants_reported_owner', sa.BOOLEAN(), nullable=True), + sa.Column('plants_reported_operator', sa.BOOLEAN(), nullable=True), + sa.Column('plants_reported_asset_manager', sa.BOOLEAN(), nullable=True), + sa.Column('plants_reported_other_relationship', sa.BOOLEAN(), nullable=True), + sa.Column('entity_type', sa.TEXT(), nullable=True), + sa.Column('attention_line', sa.TEXT(), nullable=True), + sa.Column('address_2', sa.TEXT(), nullable=True), + sa.Column('zip_code_4', sa.TEXT(), nullable=True), + sa.Column('contact_firstname', sa.TEXT(), nullable=True), + sa.Column('contact_lastname', sa.TEXT(), nullable=True), + sa.Column('contact_title', sa.TEXT(), nullable=True), + sa.Column('phone_number', sa.TEXT(), nullable=True), + sa.Column('phone_extension', sa.TEXT(), nullable=True), + sa.Column('contact_firstname_2', sa.TEXT(), nullable=True), + sa.Column('contact_lastname_2', sa.TEXT(), nullable=True), + sa.Column('contact_title_2', sa.TEXT(), nullable=True), + sa.Column('phone_number_2', sa.TEXT(), nullable=True), + sa.Column('phone_extension_2', sa.TEXT(), nullable=True), + sa.Column('data_maturity', sa.TEXT(), nullable=True), + sa.ForeignKeyConstraint(['data_maturity'], ['core_pudl__codes_data_maturities.code'], name='fk_denorm_utilities_eia_data_maturity_core_pudl__codes_data_maturities'), + sa.ForeignKeyConstraint(['utility_id_eia', 'report_date'], ['core_eia860__scd_utilities.utility_id_eia', 'core_eia860__scd_utilities.report_date'], name='fk_denorm_utilities_eia_utility_id_eia_core_eia860__scd_utilities'), + sa.ForeignKeyConstraint(['utility_id_pudl'], ['core_pudl__entity_utilities_pudl.utility_id_pudl'], name='fk_denorm_utilities_eia_utility_id_pudl_core_pudl__entity_utilities_pudl'), + sa.PrimaryKeyConstraint('utility_id_eia', 'report_date', name='pk_denorm_utilities_eia') ) op.create_table('denorm_generation_eia923', sa.Column('report_date', sa.DATE(), nullable=False), @@ -1245,6 +1202,23 @@ def downgrade() -> None: sa.ForeignKeyConstraint(['utility_id_pudl'], ['core_pudl__entity_utilities_pudl.utility_id_pudl'], name='fk_denorm_generation_eia923_utility_id_pudl_core_pudl__entity_utilities_pudl'), sa.PrimaryKeyConstraint('plant_id_eia', 'generator_id', 'report_date', name='pk_denorm_generation_eia923') ) + op.create_table('denorm_generation_monthly_eia923', + sa.Column('report_date', sa.DATE(), nullable=False), + sa.Column('plant_id_eia', sa.INTEGER(), nullable=False), + sa.Column('plant_id_pudl', sa.INTEGER(), nullable=True), + sa.Column('plant_name_eia', sa.TEXT(), nullable=True), + sa.Column('utility_id_eia', sa.INTEGER(), nullable=True), + sa.Column('utility_id_pudl', sa.INTEGER(), nullable=True), + sa.Column('utility_name_eia', sa.TEXT(), nullable=True), + sa.Column('generator_id', sa.TEXT(), nullable=False), + sa.Column('unit_id_pudl', sa.INTEGER(), nullable=True), + sa.Column('net_generation_mwh', sa.FLOAT(), nullable=True), + sa.ForeignKeyConstraint(['plant_id_eia', 'generator_id'], ['core_eia__entity_generators.plant_id_eia', 'core_eia__entity_generators.generator_id'], name='fk_denorm_generation_monthly_eia923_plant_id_eia_core_eia__entity_generators'), + sa.ForeignKeyConstraint(['plant_id_pudl'], ['core_pudl__entity_plants_pudl.plant_id_pudl'], name='fk_denorm_generation_monthly_eia923_plant_id_pudl_core_pudl__entity_plants_pudl'), + sa.ForeignKeyConstraint(['utility_id_eia'], ['core_eia__entity_utilities.utility_id_eia'], name='fk_denorm_generation_monthly_eia923_utility_id_eia_core_eia__entity_utilities'), + sa.ForeignKeyConstraint(['utility_id_pudl'], ['core_pudl__entity_utilities_pudl.utility_id_pudl'], name='fk_denorm_generation_monthly_eia923_utility_id_pudl_core_pudl__entity_utilities_pudl'), + sa.PrimaryKeyConstraint('plant_id_eia', 'generator_id', 'report_date', name='pk_denorm_generation_monthly_eia923') + ) op.create_table('denorm_generators_eia', sa.Column('report_date', sa.DATE(), nullable=False), sa.Column('plant_id_eia', sa.INTEGER(), nullable=False), @@ -1375,39 +1349,6 @@ def downgrade() -> None: sa.ForeignKeyConstraint(['utility_id_pudl'], ['core_pudl__entity_utilities_pudl.utility_id_pudl'], name='fk_denorm_generators_eia_utility_id_pudl_core_pudl__entity_utilities_pudl'), sa.PrimaryKeyConstraint('plant_id_eia', 'generator_id', 'report_date', name='pk_denorm_generators_eia') ) - op.create_table('denorm_utilities_eia', - sa.Column('utility_id_eia', sa.INTEGER(), nullable=False), - sa.Column('utility_id_pudl', sa.INTEGER(), nullable=True), - sa.Column('utility_name_eia', sa.TEXT(), nullable=True), - sa.Column('report_date', sa.DATE(), nullable=False), - sa.Column('street_address', sa.TEXT(), nullable=True), - sa.Column('city', sa.TEXT(), nullable=True), - sa.Column('state', sa.TEXT(), nullable=True), - sa.Column('zip_code', sa.TEXT(), nullable=True), - sa.Column('plants_reported_owner', sa.BOOLEAN(), nullable=True), - sa.Column('plants_reported_operator', sa.BOOLEAN(), nullable=True), - sa.Column('plants_reported_asset_manager', sa.BOOLEAN(), nullable=True), - sa.Column('plants_reported_other_relationship', sa.BOOLEAN(), nullable=True), - sa.Column('entity_type', sa.TEXT(), nullable=True), - sa.Column('attention_line', sa.TEXT(), nullable=True), - sa.Column('address_2', sa.TEXT(), nullable=True), - sa.Column('zip_code_4', sa.TEXT(), nullable=True), - sa.Column('contact_firstname', sa.TEXT(), nullable=True), - sa.Column('contact_lastname', sa.TEXT(), nullable=True), - sa.Column('contact_title', sa.TEXT(), nullable=True), - sa.Column('phone_number', sa.TEXT(), nullable=True), - sa.Column('phone_extension', sa.TEXT(), nullable=True), - sa.Column('contact_firstname_2', sa.TEXT(), nullable=True), - sa.Column('contact_lastname_2', sa.TEXT(), nullable=True), - sa.Column('contact_title_2', sa.TEXT(), nullable=True), - sa.Column('phone_number_2', sa.TEXT(), nullable=True), - sa.Column('phone_extension_2', sa.TEXT(), nullable=True), - sa.Column('data_maturity', sa.TEXT(), nullable=True), - sa.ForeignKeyConstraint(['data_maturity'], ['core_pudl__codes_data_maturities.code'], name='fk_denorm_utilities_eia_data_maturity_core_pudl__codes_data_maturities'), - sa.ForeignKeyConstraint(['utility_id_eia', 'report_date'], ['core_eia860__scd_utilities.utility_id_eia', 'core_eia860__scd_utilities.report_date'], name='fk_denorm_utilities_eia_utility_id_eia_core_eia860__scd_utilities'), - sa.ForeignKeyConstraint(['utility_id_pudl'], ['core_pudl__entity_utilities_pudl.utility_id_pudl'], name='fk_denorm_utilities_eia_utility_id_pudl_core_pudl__entity_utilities_pudl'), - sa.PrimaryKeyConstraint('utility_id_eia', 'report_date', name='pk_denorm_utilities_eia') - ) op.create_table('denorm_generation_yearly_eia923', sa.Column('report_date', sa.DATE(), nullable=False), sa.Column('plant_id_eia', sa.INTEGER(), nullable=False), @@ -1425,7 +1366,7 @@ def downgrade() -> None: sa.ForeignKeyConstraint(['utility_id_pudl'], ['core_pudl__entity_utilities_pudl.utility_id_pudl'], name='fk_denorm_generation_yearly_eia923_utility_id_pudl_core_pudl__entity_utilities_pudl'), sa.PrimaryKeyConstraint('plant_id_eia', 'generator_id', 'report_date', name='pk_denorm_generation_yearly_eia923') ) - op.create_table('denorm_generation_fuel_combined_yearly_eia923', + op.create_table('denorm_boiler_fuel_monthly_eia923', sa.Column('report_date', sa.DATE(), nullable=False), sa.Column('plant_id_eia', sa.INTEGER(), nullable=False), sa.Column('plant_id_pudl', sa.INTEGER(), nullable=True), @@ -1433,52 +1374,74 @@ def downgrade() -> None: sa.Column('utility_id_eia', sa.INTEGER(), nullable=True), sa.Column('utility_id_pudl', sa.INTEGER(), nullable=True), sa.Column('utility_name_eia', sa.TEXT(), nullable=True), + sa.Column('boiler_id', sa.TEXT(), nullable=False), + sa.Column('unit_id_pudl', sa.INTEGER(), nullable=True), sa.Column('energy_source_code', sa.TEXT(), nullable=False), - sa.Column('fuel_type_code_pudl', sa.VARCHAR(length=7), nullable=True), sa.Column('prime_mover_code', sa.TEXT(), nullable=False), + sa.Column('fuel_type_code_pudl', sa.VARCHAR(length=7), nullable=True), sa.Column('fuel_consumed_units', sa.FLOAT(), nullable=True), - sa.Column('fuel_consumed_for_electricity_units', sa.FLOAT(), nullable=True), sa.Column('fuel_mmbtu_per_unit', sa.FLOAT(), nullable=True), sa.Column('fuel_consumed_mmbtu', sa.FLOAT(), nullable=True), - sa.Column('fuel_consumed_for_electricity_mmbtu', sa.FLOAT(), nullable=True), - sa.Column('net_generation_mwh', sa.FLOAT(), nullable=True), - sa.ForeignKeyConstraint(['energy_source_code'], ['core_eia__codes_energy_sources.code'], name='fk_denorm_generation_fuel_combined_yearly_eia923_energy_source_code_core_eia__codes_energy_sources'), - sa.ForeignKeyConstraint(['plant_id_eia', 'report_date'], ['core_eia860__scd_plants.plant_id_eia', 'core_eia860__scd_plants.report_date'], name='fk_denorm_generation_fuel_combined_yearly_eia923_plant_id_eia_core_eia860__scd_plants'), - sa.ForeignKeyConstraint(['plant_id_pudl'], ['core_pudl__entity_plants_pudl.plant_id_pudl'], name='fk_denorm_generation_fuel_combined_yearly_eia923_plant_id_pudl_core_pudl__entity_plants_pudl'), - sa.ForeignKeyConstraint(['prime_mover_code'], ['core_eia__codes_prime_movers.code'], name='fk_denorm_generation_fuel_combined_yearly_eia923_prime_mover_code_core_eia__codes_prime_movers'), - sa.ForeignKeyConstraint(['utility_id_eia', 'report_date'], ['core_eia860__scd_utilities.utility_id_eia', 'core_eia860__scd_utilities.report_date'], name='fk_denorm_generation_fuel_combined_yearly_eia923_utility_id_eia_core_eia860__scd_utilities'), - sa.ForeignKeyConstraint(['utility_id_pudl'], ['core_pudl__entity_utilities_pudl.utility_id_pudl'], name='fk_denorm_generation_fuel_combined_yearly_eia923_utility_id_pudl_core_pudl__entity_utilities_pudl'), - sa.PrimaryKeyConstraint('plant_id_eia', 'report_date', 'prime_mover_code', 'energy_source_code', name='pk_denorm_generation_fuel_combined_yearly_eia923') + sa.Column('sulfur_content_pct', sa.FLOAT(), nullable=True), + sa.Column('ash_content_pct', sa.FLOAT(), nullable=True), + sa.ForeignKeyConstraint(['energy_source_code'], ['core_eia__codes_energy_sources.code'], name='fk_denorm_boiler_fuel_monthly_eia923_energy_source_code_core_eia__codes_energy_sources'), + sa.ForeignKeyConstraint(['plant_id_eia', 'boiler_id'], ['core_eia__entity_boilers.plant_id_eia', 'core_eia__entity_boilers.boiler_id'], name='fk_denorm_boiler_fuel_monthly_eia923_plant_id_eia_core_eia__entity_boilers'), + sa.ForeignKeyConstraint(['plant_id_pudl'], ['core_pudl__entity_plants_pudl.plant_id_pudl'], name='fk_denorm_boiler_fuel_monthly_eia923_plant_id_pudl_core_pudl__entity_plants_pudl'), + sa.ForeignKeyConstraint(['prime_mover_code'], ['core_eia__codes_prime_movers.code'], name='fk_denorm_boiler_fuel_monthly_eia923_prime_mover_code_core_eia__codes_prime_movers'), + sa.ForeignKeyConstraint(['utility_id_eia'], ['core_eia__entity_utilities.utility_id_eia'], name='fk_denorm_boiler_fuel_monthly_eia923_utility_id_eia_core_eia__entity_utilities'), + sa.ForeignKeyConstraint(['utility_id_pudl'], ['core_pudl__entity_utilities_pudl.utility_id_pudl'], name='fk_denorm_boiler_fuel_monthly_eia923_utility_id_pudl_core_pudl__entity_utilities_pudl'), + sa.PrimaryKeyConstraint('plant_id_eia', 'boiler_id', 'energy_source_code', 'prime_mover_code', 'report_date', name='pk_denorm_boiler_fuel_monthly_eia923') ) - op.create_table('denorm_emissions_control_equipment_eia860', - sa.Column('report_year', sa.INTEGER(), nullable=False), + op.create_table('denorm_fuel_receipts_costs_monthly_eia923', + sa.Column('report_date', sa.DATE(), nullable=True), + sa.Column('plant_id_eia', sa.INTEGER(), nullable=True), + sa.Column('plant_id_pudl', sa.INTEGER(), nullable=True), + sa.Column('plant_name_eia', sa.TEXT(), nullable=True), + sa.Column('utility_id_eia', sa.INTEGER(), nullable=True), + sa.Column('utility_id_pudl', sa.INTEGER(), nullable=True), + sa.Column('utility_name_eia', sa.TEXT(), nullable=True), + sa.Column('state', sa.TEXT(), nullable=True), + sa.Column('fuel_type_code_pudl', sa.VARCHAR(length=7), nullable=True), + sa.Column('fuel_received_units', sa.FLOAT(), nullable=True), + sa.Column('fuel_mmbtu_per_unit', sa.FLOAT(), nullable=True), + sa.Column('fuel_cost_per_mmbtu', sa.FLOAT(), nullable=True), + sa.Column('fuel_consumed_mmbtu', sa.FLOAT(), nullable=True), + sa.Column('total_fuel_cost', sa.FLOAT(), nullable=True), + sa.Column('fuel_cost_from_eiaapi', sa.BOOLEAN(), nullable=True), + sa.Column('sulfur_content_pct', sa.FLOAT(), nullable=True), + sa.Column('ash_content_pct', sa.FLOAT(), nullable=True), + sa.Column('mercury_content_ppm', sa.FLOAT(), nullable=True), + sa.Column('moisture_content_pct', sa.FLOAT(), nullable=True), + sa.Column('chlorine_content_ppm', sa.FLOAT(), nullable=True), + sa.ForeignKeyConstraint(['plant_id_eia'], ['core_eia__entity_plants.plant_id_eia'], name='fk_denorm_fuel_receipts_costs_monthly_eia923_plant_id_eia_core_eia__entity_plants'), + sa.ForeignKeyConstraint(['plant_id_pudl'], ['core_pudl__entity_plants_pudl.plant_id_pudl'], name='fk_denorm_fuel_receipts_costs_monthly_eia923_plant_id_pudl_core_pudl__entity_plants_pudl'), + sa.ForeignKeyConstraint(['utility_id_eia'], ['core_eia__entity_utilities.utility_id_eia'], name='fk_denorm_fuel_receipts_costs_monthly_eia923_utility_id_eia_core_eia__entity_utilities'), + sa.ForeignKeyConstraint(['utility_id_pudl'], ['core_pudl__entity_utilities_pudl.utility_id_pudl'], name='fk_denorm_fuel_receipts_costs_monthly_eia923_utility_id_pudl_core_pudl__entity_utilities_pudl') + ) + op.create_table('denorm_ownership_eia860', + sa.Column('report_date', sa.DATE(), nullable=False), sa.Column('plant_id_eia', sa.INTEGER(), nullable=False), sa.Column('plant_id_pudl', sa.INTEGER(), nullable=True), sa.Column('plant_name_eia', sa.TEXT(), nullable=True), sa.Column('utility_id_eia', sa.INTEGER(), nullable=True), sa.Column('utility_id_pudl', sa.INTEGER(), nullable=True), sa.Column('utility_name_eia', sa.TEXT(), nullable=True), - sa.Column('emission_control_id_pudl', sa.FLOAT(), nullable=False), + sa.Column('generator_id', sa.TEXT(), nullable=False), + sa.Column('owner_utility_id_eia', sa.INTEGER(), nullable=False), + sa.Column('owner_name', sa.TEXT(), nullable=True), + sa.Column('owner_state', sa.VARCHAR(length=2), nullable=True), + sa.Column('owner_city', sa.TEXT(), nullable=True), + sa.Column('owner_country', sa.VARCHAR(length=3), nullable=True), + sa.Column('owner_street_address', sa.TEXT(), nullable=True), + sa.Column('owner_zip_code', sa.TEXT(), nullable=True), + sa.Column('fraction_owned', sa.FLOAT(), nullable=True), sa.Column('data_maturity', sa.TEXT(), nullable=True), - sa.Column('emission_control_equipment_type_code', sa.TEXT(), nullable=True), - sa.Column('operational_status_code', sa.TEXT(), nullable=True), - sa.Column('operational_status', sa.TEXT(), nullable=True), - sa.Column('mercury_control_id_eia', sa.TEXT(), nullable=True), - sa.Column('nox_control_id_eia', sa.TEXT(), nullable=True), - sa.Column('particulate_control_id_eia', sa.TEXT(), nullable=True), - sa.Column('so2_control_id_eia', sa.TEXT(), nullable=True), - sa.Column('acid_gas_control', sa.BOOLEAN(), nullable=True), - sa.Column('emission_control_equipment_cost', sa.FLOAT(), nullable=True), - sa.Column('emission_control_operating_date', sa.DATE(), nullable=True), - sa.Column('emission_control_retirement_date', sa.DATE(), nullable=True), - sa.ForeignKeyConstraint(['data_maturity'], ['core_pudl__codes_data_maturities.code'], name='fk_denorm_emissions_control_equipment_eia860_data_maturity_core_pudl__codes_data_maturities'), - sa.ForeignKeyConstraint(['emission_control_equipment_type_code'], ['core_eia__codes_emission_control_equipment_types.code'], name='fk_denorm_emissions_control_equipment_eia860_emission_control_equipment_type_code_core_eia__codes_emission_control_equipment_types'), - sa.ForeignKeyConstraint(['operational_status_code'], ['core_eia__codes_operational_status.code'], name='fk_denorm_emissions_control_equipment_eia860_operational_status_code_core_eia__codes_operational_status'), - sa.ForeignKeyConstraint(['plant_id_eia'], ['core_eia__entity_plants.plant_id_eia'], name='fk_denorm_emissions_control_equipment_eia860_plant_id_eia_core_eia__entity_plants'), - sa.ForeignKeyConstraint(['plant_id_pudl'], ['core_pudl__entity_plants_pudl.plant_id_pudl'], name='fk_denorm_emissions_control_equipment_eia860_plant_id_pudl_core_pudl__entity_plants_pudl'), - sa.ForeignKeyConstraint(['utility_id_eia'], ['core_eia__entity_utilities.utility_id_eia'], name='fk_denorm_emissions_control_equipment_eia860_utility_id_eia_core_eia__entity_utilities'), - sa.ForeignKeyConstraint(['utility_id_pudl'], ['core_pudl__entity_utilities_pudl.utility_id_pudl'], name='fk_denorm_emissions_control_equipment_eia860_utility_id_pudl_core_pudl__entity_utilities_pudl'), - sa.PrimaryKeyConstraint('report_year', 'plant_id_eia', 'emission_control_id_pudl', name='pk_denorm_emissions_control_equipment_eia860') + sa.ForeignKeyConstraint(['data_maturity'], ['core_pudl__codes_data_maturities.code'], name='fk_denorm_ownership_eia860_data_maturity_core_pudl__codes_data_maturities'), + sa.ForeignKeyConstraint(['plant_id_eia', 'generator_id', 'report_date'], ['core_eia860__scd_generators.plant_id_eia', 'core_eia860__scd_generators.generator_id', 'core_eia860__scd_generators.report_date'], name='fk_denorm_ownership_eia860_plant_id_eia_core_eia860__scd_generators'), + sa.ForeignKeyConstraint(['plant_id_pudl'], ['core_pudl__entity_plants_pudl.plant_id_pudl'], name='fk_denorm_ownership_eia860_plant_id_pudl_core_pudl__entity_plants_pudl'), + sa.ForeignKeyConstraint(['utility_id_eia', 'report_date'], ['core_eia860__scd_utilities.utility_id_eia', 'core_eia860__scd_utilities.report_date'], name='fk_denorm_ownership_eia860_utility_id_eia_core_eia860__scd_utilities'), + sa.ForeignKeyConstraint(['utility_id_pudl'], ['core_pudl__entity_utilities_pudl.utility_id_pudl'], name='fk_denorm_ownership_eia860_utility_id_pudl_core_pudl__entity_utilities_pudl'), + sa.PrimaryKeyConstraint('report_date', 'plant_id_eia', 'generator_id', 'owner_utility_id_eia', name='pk_denorm_ownership_eia860') ) op.create_table('denorm_boiler_fuel_eia923', sa.Column('report_date', sa.DATE(), nullable=False), @@ -1506,69 +1469,97 @@ def downgrade() -> None: sa.ForeignKeyConstraint(['utility_id_pudl'], ['core_pudl__entity_utilities_pudl.utility_id_pudl'], name='fk_denorm_boiler_fuel_eia923_utility_id_pudl_core_pudl__entity_utilities_pudl'), sa.PrimaryKeyConstraint('plant_id_eia', 'boiler_id', 'energy_source_code', 'prime_mover_code', 'report_date', name='pk_denorm_boiler_fuel_eia923') ) - op.create_table('denorm_plants_utilities_eia', - sa.Column('report_date', sa.DATE(), nullable=False), + op.create_table('denorm_plants_eia', sa.Column('plant_id_eia', sa.INTEGER(), nullable=False), sa.Column('plant_name_eia', sa.TEXT(), nullable=True), + sa.Column('city', sa.TEXT(), nullable=True), + sa.Column('county', sa.TEXT(), nullable=True), + sa.Column('latitude', sa.FLOAT(), nullable=True), + sa.Column('longitude', sa.FLOAT(), nullable=True), + sa.Column('state', sa.TEXT(), nullable=True), + sa.Column('street_address', sa.TEXT(), nullable=True), + sa.Column('zip_code', sa.TEXT(), nullable=True), + sa.Column('timezone', sa.VARCHAR(length=32), nullable=True), + sa.Column('report_date', sa.DATE(), nullable=False), + sa.Column('ash_impoundment', sa.BOOLEAN(), nullable=True), + sa.Column('ash_impoundment_lined', sa.BOOLEAN(), nullable=True), + sa.Column('ash_impoundment_status', sa.TEXT(), nullable=True), + sa.Column('balancing_authority_code_eia', sa.TEXT(), nullable=True), + sa.Column('balancing_authority_name_eia', sa.TEXT(), nullable=True), + sa.Column('datum', sa.TEXT(), nullable=True), + sa.Column('energy_storage', sa.BOOLEAN(), nullable=True), + sa.Column('ferc_cogen_docket_no', sa.TEXT(), nullable=True), + sa.Column('ferc_cogen_status', sa.BOOLEAN(), nullable=True), + sa.Column('ferc_exempt_wholesale_generator_docket_no', sa.TEXT(), nullable=True), + sa.Column('ferc_exempt_wholesale_generator', sa.BOOLEAN(), nullable=True), + sa.Column('ferc_small_power_producer_docket_no', sa.TEXT(), nullable=True), + sa.Column('ferc_small_power_producer', sa.BOOLEAN(), nullable=True), + sa.Column('ferc_qualifying_facility_docket_no', sa.TEXT(), nullable=True), + sa.Column('grid_voltage_1_kv', sa.FLOAT(), nullable=True), + sa.Column('grid_voltage_2_kv', sa.FLOAT(), nullable=True), + sa.Column('grid_voltage_3_kv', sa.FLOAT(), nullable=True), + sa.Column('iso_rto_code', sa.TEXT(), nullable=True), + sa.Column('liquefied_natural_gas_storage', sa.BOOLEAN(), nullable=True), + sa.Column('natural_gas_local_distribution_company', sa.TEXT(), nullable=True), + sa.Column('natural_gas_storage', sa.BOOLEAN(), nullable=True), + sa.Column('natural_gas_pipeline_name_1', sa.TEXT(), nullable=True), + sa.Column('natural_gas_pipeline_name_2', sa.TEXT(), nullable=True), + sa.Column('natural_gas_pipeline_name_3', sa.TEXT(), nullable=True), + sa.Column('nerc_region', sa.VARCHAR(length=9), nullable=True), + sa.Column('net_metering', sa.BOOLEAN(), nullable=True), + sa.Column('pipeline_notes', sa.TEXT(), nullable=True), + sa.Column('primary_purpose_id_naics', sa.INTEGER(), nullable=True), + sa.Column('regulatory_status_code', sa.TEXT(), nullable=True), + sa.Column('reporting_frequency_code', sa.VARCHAR(length=2), nullable=True), + sa.Column('sector_id_eia', sa.INTEGER(), nullable=True), + sa.Column('sector_name_eia', sa.TEXT(), nullable=True), + sa.Column('service_area', sa.TEXT(), nullable=True), + sa.Column('transmission_distribution_owner_id', sa.INTEGER(), nullable=True), + sa.Column('transmission_distribution_owner_name', sa.TEXT(), nullable=True), + sa.Column('transmission_distribution_owner_state', sa.TEXT(), nullable=True), + sa.Column('utility_id_eia', sa.INTEGER(), nullable=True), + sa.Column('water_source', sa.TEXT(), nullable=True), + sa.Column('data_maturity', sa.TEXT(), nullable=True), sa.Column('plant_id_pudl', sa.INTEGER(), nullable=True), - sa.Column('utility_id_eia', sa.INTEGER(), nullable=False), sa.Column('utility_name_eia', sa.TEXT(), nullable=True), sa.Column('utility_id_pudl', sa.INTEGER(), nullable=True), - sa.ForeignKeyConstraint(['plant_id_eia', 'report_date'], ['core_eia860__scd_plants.plant_id_eia', 'core_eia860__scd_plants.report_date'], name='fk_denorm_plants_utilities_eia_plant_id_eia_core_eia860__scd_plants'), - sa.ForeignKeyConstraint(['plant_id_pudl'], ['core_pudl__entity_plants_pudl.plant_id_pudl'], name='fk_denorm_plants_utilities_eia_plant_id_pudl_core_pudl__entity_plants_pudl'), - sa.ForeignKeyConstraint(['utility_id_eia', 'report_date'], ['core_eia860__scd_utilities.utility_id_eia', 'core_eia860__scd_utilities.report_date'], name='fk_denorm_plants_utilities_eia_utility_id_eia_core_eia860__scd_utilities'), - sa.ForeignKeyConstraint(['utility_id_pudl'], ['core_pudl__entity_utilities_pudl.utility_id_pudl'], name='fk_denorm_plants_utilities_eia_utility_id_pudl_core_pudl__entity_utilities_pudl'), - sa.PrimaryKeyConstraint('report_date', 'plant_id_eia', 'utility_id_eia', name='pk_denorm_plants_utilities_eia') + sa.Column('balancing_authority_code_eia_consistent_rate', sa.FLOAT(), nullable=True), + sa.ForeignKeyConstraint(['balancing_authority_code_eia'], ['core_eia__codes_balancing_authorities.code'], name='fk_denorm_plants_eia_balancing_authority_code_eia_core_eia__codes_balancing_authorities'), + sa.ForeignKeyConstraint(['data_maturity'], ['core_pudl__codes_data_maturities.code'], name='fk_denorm_plants_eia_data_maturity_core_pudl__codes_data_maturities'), + sa.ForeignKeyConstraint(['plant_id_eia', 'report_date'], ['core_eia860__scd_plants.plant_id_eia', 'core_eia860__scd_plants.report_date'], name='fk_denorm_plants_eia_plant_id_eia_core_eia860__scd_plants'), + sa.ForeignKeyConstraint(['plant_id_pudl'], ['core_pudl__entity_plants_pudl.plant_id_pudl'], name='fk_denorm_plants_eia_plant_id_pudl_core_pudl__entity_plants_pudl'), + sa.ForeignKeyConstraint(['reporting_frequency_code'], ['core_eia__codes_reporting_frequencies.code'], name='fk_denorm_plants_eia_reporting_frequency_code_core_eia__codes_reporting_frequencies'), + sa.ForeignKeyConstraint(['sector_id_eia'], ['core_eia__codes_sector_consolidated.code'], name='fk_denorm_plants_eia_sector_id_eia_core_eia__codes_sector_consolidated'), + sa.ForeignKeyConstraint(['utility_id_eia', 'report_date'], ['core_eia860__scd_utilities.utility_id_eia', 'core_eia860__scd_utilities.report_date'], name='fk_denorm_plants_eia_utility_id_eia_core_eia860__scd_utilities'), + sa.ForeignKeyConstraint(['utility_id_pudl'], ['core_pudl__entity_utilities_pudl.utility_id_pudl'], name='fk_denorm_plants_eia_utility_id_pudl_core_pudl__entity_utilities_pudl'), + sa.PrimaryKeyConstraint('plant_id_eia', 'report_date', name='pk_denorm_plants_eia') ) - op.create_table('denorm_fuel_receipts_costs_eia923', - sa.Column('report_date', sa.DATE(), nullable=True), - sa.Column('plant_id_eia', sa.INTEGER(), nullable=True), + op.create_table('denorm_generation_fuel_combined_monthly_eia923', + sa.Column('report_date', sa.DATE(), nullable=False), + sa.Column('plant_id_eia', sa.INTEGER(), nullable=False), sa.Column('plant_id_pudl', sa.INTEGER(), nullable=True), sa.Column('plant_name_eia', sa.TEXT(), nullable=True), sa.Column('utility_id_eia', sa.INTEGER(), nullable=True), sa.Column('utility_id_pudl', sa.INTEGER(), nullable=True), sa.Column('utility_name_eia', sa.TEXT(), nullable=True), - sa.Column('state', sa.TEXT(), nullable=True), - sa.Column('contract_type_code', sa.VARCHAR(length=2), nullable=True), - sa.Column('contract_expiration_date', sa.DATE(), nullable=True), - sa.Column('energy_source_code', sa.TEXT(), nullable=True), + sa.Column('energy_source_code', sa.TEXT(), nullable=False), sa.Column('fuel_type_code_pudl', sa.VARCHAR(length=7), nullable=True), - sa.Column('fuel_group_code', sa.VARCHAR(length=14), nullable=True), - sa.Column('supplier_name', sa.TEXT(), nullable=True), - sa.Column('fuel_received_units', sa.FLOAT(), nullable=True), + sa.Column('prime_mover_code', sa.TEXT(), nullable=False), + sa.Column('fuel_consumed_units', sa.FLOAT(), nullable=True), + sa.Column('fuel_consumed_for_electricity_units', sa.FLOAT(), nullable=True), sa.Column('fuel_mmbtu_per_unit', sa.FLOAT(), nullable=True), - sa.Column('fuel_cost_per_mmbtu', sa.FLOAT(), nullable=True), - sa.Column('bulk_agg_fuel_cost_per_mmbtu', sa.FLOAT(), nullable=True), sa.Column('fuel_consumed_mmbtu', sa.FLOAT(), nullable=True), - sa.Column('total_fuel_cost', sa.FLOAT(), nullable=True), - sa.Column('fuel_cost_from_eiaapi', sa.BOOLEAN(), nullable=True), - sa.Column('sulfur_content_pct', sa.FLOAT(), nullable=True), - sa.Column('ash_content_pct', sa.FLOAT(), nullable=True), - sa.Column('mercury_content_ppm', sa.FLOAT(), nullable=True), - sa.Column('primary_transportation_mode_code', sa.TEXT(), nullable=True), - sa.Column('secondary_transportation_mode_code', sa.TEXT(), nullable=True), - sa.Column('natural_gas_transport_code', sa.VARCHAR(length=13), nullable=True), - sa.Column('natural_gas_delivery_contract_type_code', sa.VARCHAR(length=13), nullable=True), - sa.Column('moisture_content_pct', sa.FLOAT(), nullable=True), - sa.Column('chlorine_content_ppm', sa.FLOAT(), nullable=True), - sa.Column('data_maturity', sa.TEXT(), nullable=True), - sa.Column('mine_id_msha', sa.INTEGER(), nullable=True), - sa.Column('mine_name', sa.TEXT(), nullable=True), - sa.Column('mine_state', sa.TEXT(), nullable=True), - sa.Column('coalmine_county_id_fips', sa.TEXT(), nullable=True), - sa.Column('mine_type_code', sa.TEXT(), nullable=True), - sa.ForeignKeyConstraint(['contract_type_code'], ['core_eia__codes_contract_types.code'], name='fk_denorm_fuel_receipts_costs_eia923_contract_type_code_core_eia__codes_contract_types'), - sa.ForeignKeyConstraint(['data_maturity'], ['core_pudl__codes_data_maturities.code'], name='fk_denorm_fuel_receipts_costs_eia923_data_maturity_core_pudl__codes_data_maturities'), - sa.ForeignKeyConstraint(['energy_source_code'], ['core_eia__codes_energy_sources.code'], name='fk_denorm_fuel_receipts_costs_eia923_energy_source_code_core_eia__codes_energy_sources'), - sa.ForeignKeyConstraint(['mine_type_code'], ['core_eia__codes_coalmine_types.code'], name='fk_denorm_fuel_receipts_costs_eia923_mine_type_code_core_eia__codes_coalmine_types'), - sa.ForeignKeyConstraint(['plant_id_eia'], ['core_eia__entity_plants.plant_id_eia'], name='fk_denorm_fuel_receipts_costs_eia923_plant_id_eia_core_eia__entity_plants'), - sa.ForeignKeyConstraint(['plant_id_pudl'], ['core_pudl__entity_plants_pudl.plant_id_pudl'], name='fk_denorm_fuel_receipts_costs_eia923_plant_id_pudl_core_pudl__entity_plants_pudl'), - sa.ForeignKeyConstraint(['primary_transportation_mode_code'], ['core_eia__codes_fuel_transportation_modes.code'], name='fk_denorm_fuel_receipts_costs_eia923_primary_transportation_mode_code_core_eia__codes_fuel_transportation_modes'), - sa.ForeignKeyConstraint(['secondary_transportation_mode_code'], ['core_eia__codes_fuel_transportation_modes.code'], name='fk_denorm_fuel_receipts_costs_eia923_secondary_transportation_mode_code_core_eia__codes_fuel_transportation_modes'), - sa.ForeignKeyConstraint(['utility_id_eia'], ['core_eia__entity_utilities.utility_id_eia'], name='fk_denorm_fuel_receipts_costs_eia923_utility_id_eia_core_eia__entity_utilities'), - sa.ForeignKeyConstraint(['utility_id_pudl'], ['core_pudl__entity_utilities_pudl.utility_id_pudl'], name='fk_denorm_fuel_receipts_costs_eia923_utility_id_pudl_core_pudl__entity_utilities_pudl') + sa.Column('fuel_consumed_for_electricity_mmbtu', sa.FLOAT(), nullable=True), + sa.Column('net_generation_mwh', sa.FLOAT(), nullable=True), + sa.ForeignKeyConstraint(['energy_source_code'], ['core_eia__codes_energy_sources.code'], name='fk_denorm_generation_fuel_combined_monthly_eia923_energy_source_code_core_eia__codes_energy_sources'), + sa.ForeignKeyConstraint(['plant_id_eia'], ['core_eia__entity_plants.plant_id_eia'], name='fk_denorm_generation_fuel_combined_monthly_eia923_plant_id_eia_core_eia__entity_plants'), + sa.ForeignKeyConstraint(['plant_id_pudl'], ['core_pudl__entity_plants_pudl.plant_id_pudl'], name='fk_denorm_generation_fuel_combined_monthly_eia923_plant_id_pudl_core_pudl__entity_plants_pudl'), + sa.ForeignKeyConstraint(['prime_mover_code'], ['core_eia__codes_prime_movers.code'], name='fk_denorm_generation_fuel_combined_monthly_eia923_prime_mover_code_core_eia__codes_prime_movers'), + sa.ForeignKeyConstraint(['utility_id_eia'], ['core_eia__entity_utilities.utility_id_eia'], name='fk_denorm_generation_fuel_combined_monthly_eia923_utility_id_eia_core_eia__entity_utilities'), + sa.ForeignKeyConstraint(['utility_id_pudl'], ['core_pudl__entity_utilities_pudl.utility_id_pudl'], name='fk_denorm_generation_fuel_combined_monthly_eia923_utility_id_pudl_core_pudl__entity_utilities_pudl'), + sa.PrimaryKeyConstraint('plant_id_eia', 'report_date', 'prime_mover_code', 'energy_source_code', name='pk_denorm_generation_fuel_combined_monthly_eia923') ) - op.create_table('denorm_generation_monthly_eia923', + op.create_table('denorm_boiler_fuel_yearly_eia923', sa.Column('report_date', sa.DATE(), nullable=False), sa.Column('plant_id_eia', sa.INTEGER(), nullable=False), sa.Column('plant_id_pudl', sa.INTEGER(), nullable=True), @@ -1576,14 +1567,23 @@ def downgrade() -> None: sa.Column('utility_id_eia', sa.INTEGER(), nullable=True), sa.Column('utility_id_pudl', sa.INTEGER(), nullable=True), sa.Column('utility_name_eia', sa.TEXT(), nullable=True), - sa.Column('generator_id', sa.TEXT(), nullable=False), + sa.Column('boiler_id', sa.TEXT(), nullable=False), sa.Column('unit_id_pudl', sa.INTEGER(), nullable=True), - sa.Column('net_generation_mwh', sa.FLOAT(), nullable=True), - sa.ForeignKeyConstraint(['plant_id_eia', 'generator_id'], ['core_eia__entity_generators.plant_id_eia', 'core_eia__entity_generators.generator_id'], name='fk_denorm_generation_monthly_eia923_plant_id_eia_core_eia__entity_generators'), - sa.ForeignKeyConstraint(['plant_id_pudl'], ['core_pudl__entity_plants_pudl.plant_id_pudl'], name='fk_denorm_generation_monthly_eia923_plant_id_pudl_core_pudl__entity_plants_pudl'), - sa.ForeignKeyConstraint(['utility_id_eia'], ['core_eia__entity_utilities.utility_id_eia'], name='fk_denorm_generation_monthly_eia923_utility_id_eia_core_eia__entity_utilities'), - sa.ForeignKeyConstraint(['utility_id_pudl'], ['core_pudl__entity_utilities_pudl.utility_id_pudl'], name='fk_denorm_generation_monthly_eia923_utility_id_pudl_core_pudl__entity_utilities_pudl'), - sa.PrimaryKeyConstraint('plant_id_eia', 'generator_id', 'report_date', name='pk_denorm_generation_monthly_eia923') + sa.Column('energy_source_code', sa.TEXT(), nullable=False), + sa.Column('prime_mover_code', sa.TEXT(), nullable=False), + sa.Column('fuel_type_code_pudl', sa.VARCHAR(length=7), nullable=True), + sa.Column('fuel_consumed_units', sa.FLOAT(), nullable=True), + sa.Column('fuel_mmbtu_per_unit', sa.FLOAT(), nullable=True), + sa.Column('fuel_consumed_mmbtu', sa.FLOAT(), nullable=True), + sa.Column('sulfur_content_pct', sa.FLOAT(), nullable=True), + sa.Column('ash_content_pct', sa.FLOAT(), nullable=True), + sa.ForeignKeyConstraint(['energy_source_code'], ['core_eia__codes_energy_sources.code'], name='fk_denorm_boiler_fuel_yearly_eia923_energy_source_code_core_eia__codes_energy_sources'), + sa.ForeignKeyConstraint(['plant_id_eia', 'boiler_id', 'report_date'], ['core_eia860__scd_boilers.plant_id_eia', 'core_eia860__scd_boilers.boiler_id', 'core_eia860__scd_boilers.report_date'], name='fk_denorm_boiler_fuel_yearly_eia923_plant_id_eia_core_eia860__scd_boilers'), + sa.ForeignKeyConstraint(['plant_id_pudl'], ['core_pudl__entity_plants_pudl.plant_id_pudl'], name='fk_denorm_boiler_fuel_yearly_eia923_plant_id_pudl_core_pudl__entity_plants_pudl'), + sa.ForeignKeyConstraint(['prime_mover_code'], ['core_eia__codes_prime_movers.code'], name='fk_denorm_boiler_fuel_yearly_eia923_prime_mover_code_core_eia__codes_prime_movers'), + sa.ForeignKeyConstraint(['utility_id_eia', 'report_date'], ['core_eia860__scd_utilities.utility_id_eia', 'core_eia860__scd_utilities.report_date'], name='fk_denorm_boiler_fuel_yearly_eia923_utility_id_eia_core_eia860__scd_utilities'), + sa.ForeignKeyConstraint(['utility_id_pudl'], ['core_pudl__entity_utilities_pudl.utility_id_pudl'], name='fk_denorm_boiler_fuel_yearly_eia923_utility_id_pudl_core_pudl__entity_utilities_pudl'), + sa.PrimaryKeyConstraint('plant_id_eia', 'boiler_id', 'energy_source_code', 'prime_mover_code', 'report_date', name='pk_denorm_boiler_fuel_yearly_eia923') ) op.drop_table('out_eia__yearly_generators') op.drop_table('out_eia__yearly_boilers')