-
-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2865 from catalyst-cooperative/rename-allocate-ge…
…n-fuel-assets Rename allocate net generation fuel assets
- Loading branch information
Showing
10 changed files
with
740 additions
and
23 deletions.
There are no files selected for viewing
606 changes: 606 additions & 0 deletions
606
migrations/versions/62f1f694f6af_rename_allocate_gen_fuel_assets.py
Large diffs are not rendered by default.
Oops, something went wrong.
65 changes: 65 additions & 0 deletions
65
migrations/versions/d4149ca95fa9_rename_yearly_generation_fuel_by_.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
"""Rename yearly_generation_fuel_by_generator_energy_source_owner | ||
Revision ID: d4149ca95fa9 | ||
Revises: 62f1f694f6af | ||
Create Date: 2023-09-18 12:29:19.219934 | ||
""" | ||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'd4149ca95fa9' | ||
down_revision = '62f1f694f6af' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table('out_eia923__yearly_generation_fuel_by_generator_energy_source_owner', | ||
sa.Column('report_date', sa.Date(), nullable=False, comment='Date reported.'), | ||
sa.Column('plant_id_eia', sa.Integer(), nullable=False, comment='The unique six-digit facility identification number, also called an ORISPL, assigned by the Energy Information Administration.'), | ||
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('prime_mover_code', sa.Text(), nullable=False, comment='Code for the type of prime mover (e.g. CT, CG)'), | ||
sa.Column('energy_source_code', sa.Text(), nullable=False, comment='A 2-3 letter code indicating the energy source (e.g. fuel type) associated with the record.'), | ||
sa.Column('utility_id_eia', sa.Integer(), nullable=False, comment='The EIA Utility Identification number.'), | ||
sa.Column('ownership_record_type', sa.Enum('owned', 'total'), nullable=False, comment='Whether each generator record is for one owner or represents a total of all ownerships.'), | ||
sa.Column('fraction_owned', sa.Float(), nullable=True, comment='Proportion of generator ownership attributable to this utility.'), | ||
sa.Column('capacity_mw', sa.Float(), nullable=True, comment='Total installed (nameplate) capacity, in megawatts.'), | ||
sa.Column('energy_source_code_num', sa.Enum('energy_source_code_1', 'energy_source_code_2', 'energy_source_code_3', 'energy_source_code_4', 'energy_source_code_5', 'energy_source_code_6', 'energy_source_code_7', 'energy_source_code_8'), nullable=True, comment='Name of the energy_source_code_N column that this energy source code was reported in for the generator referenced in the same record.'), | ||
sa.Column('net_generation_mwh', sa.Float(), nullable=True, comment='Net electricity generation for the specified period in megawatt-hours (MWh).'), | ||
sa.Column('fuel_consumed_mmbtu', sa.Float(), nullable=True, comment='Total consumption of fuel in physical unit, year to date. Note: this is the total quantity consumed for both electricity and, in the case of combined heat and power plants, process steam production.'), | ||
sa.Column('fuel_consumed_for_electricity_mmbtu', sa.Float(), nullable=True, comment='Total consumption of fuel to produce electricity, in physical unit, year to date.'), | ||
sa.ForeignKeyConstraint(['energy_source_code'], ['core_eia__codes_energy_sources.code'], name=op.f('fk_out_eia923__yearly_generation_fuel_by_generator_energy_source_owner_energy_source_code_core_eia__codes_energy_sources')), | ||
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=op.f('fk_out_eia923__yearly_generation_fuel_by_generator_energy_source_owner_plant_id_eia_core_eia860__scd_generators')), | ||
sa.ForeignKeyConstraint(['prime_mover_code'], ['core_eia__codes_prime_movers.code'], name=op.f('fk_out_eia923__yearly_generation_fuel_by_generator_energy_source_owner_prime_mover_code_core_eia__codes_prime_movers')), | ||
sa.PrimaryKeyConstraint('report_date', 'plant_id_eia', 'generator_id', 'prime_mover_code', 'energy_source_code', 'utility_id_eia', 'ownership_record_type', name=op.f('pk_out_eia923__yearly_generation_fuel_by_generator_energy_source_owner')) | ||
) | ||
op.drop_table('generation_fuel_by_generator_energy_source_owner_yearly_eia923') | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table('generation_fuel_by_generator_energy_source_owner_yearly_eia923', | ||
sa.Column('report_date', sa.DATE(), nullable=False), | ||
sa.Column('plant_id_eia', sa.INTEGER(), nullable=False), | ||
sa.Column('generator_id', sa.TEXT(), nullable=False), | ||
sa.Column('prime_mover_code', sa.TEXT(), nullable=False), | ||
sa.Column('energy_source_code', sa.TEXT(), nullable=False), | ||
sa.Column('utility_id_eia', sa.INTEGER(), nullable=False), | ||
sa.Column('ownership_record_type', sa.VARCHAR(length=5), nullable=False), | ||
sa.Column('fraction_owned', sa.FLOAT(), nullable=True), | ||
sa.Column('capacity_mw', sa.FLOAT(), nullable=True), | ||
sa.Column('energy_source_code_num', sa.VARCHAR(length=20), nullable=True), | ||
sa.Column('net_generation_mwh', 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.ForeignKeyConstraint(['energy_source_code'], ['core_eia__codes_energy_sources.code'], name='fk_generation_fuel_by_generator_energy_source_owner_yearly_eia923_energy_source_code_core_eia__codes_energy_sources'), | ||
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_generation_fuel_by_generator_energy_source_owner_yearly_eia923_plant_id_eia_core_eia860__scd_generators'), | ||
sa.ForeignKeyConstraint(['prime_mover_code'], ['core_eia__codes_prime_movers.code'], name='fk_generation_fuel_by_generator_energy_source_owner_yearly_eia923_prime_mover_code_core_eia__codes_prime_movers'), | ||
sa.PrimaryKeyConstraint('report_date', 'plant_id_eia', 'generator_id', 'prime_mover_code', 'energy_source_code', 'utility_id_eia', 'ownership_record_type', name='pk_generation_fuel_by_generator_energy_source_owner_yearly_eia923') | ||
) | ||
op.drop_table('out_eia923__yearly_generation_fuel_by_generator_energy_source_owner') | ||
# ### end Alembic commands ### |
44 changes: 44 additions & 0 deletions
44
migrations/versions/dfbc19b1cb34_update_allocate_gen_fuel_fk.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
"""Update allocate gen fuel fk | ||
Revision ID: dfbc19b1cb34 | ||
Revises: d4149ca95fa9 | ||
Create Date: 2023-09-18 15:09:36.838769 | ||
""" | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'dfbc19b1cb34' | ||
down_revision = 'd4149ca95fa9' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
with op.batch_alter_table('out_eia923__monthly_generation_fuel_by_generator', schema=None) as batch_op: | ||
batch_op.drop_constraint('fk_out_eia923__monthly_generation_fuel_by_generator_utility_id_eia_core_eia860__scd_utilities', type_='foreignkey') | ||
batch_op.drop_constraint('fk_out_eia923__monthly_generation_fuel_by_generator_plant_id_eia_core_eia860__scd_generators', type_='foreignkey') | ||
batch_op.create_foreign_key(batch_op.f('fk_out_eia923__monthly_generation_fuel_by_generator_utility_id_eia_core_eia__entity_utilities'), 'core_eia__entity_utilities', ['utility_id_eia'], ['utility_id_eia']) | ||
batch_op.create_foreign_key(batch_op.f('fk_out_eia923__monthly_generation_fuel_by_generator_plant_id_eia_core_eia__entity_generators'), 'core_eia__entity_generators', ['plant_id_eia', 'generator_id'], ['plant_id_eia', 'generator_id']) | ||
|
||
with op.batch_alter_table('out_eia923__monthly_generation_fuel_by_generator_energy_source', schema=None) as batch_op: | ||
batch_op.drop_constraint('fk_out_eia923__monthly_generation_fuel_by_generator_energy_source_plant_id_eia_core_eia860__scd_generators', type_='foreignkey') | ||
batch_op.create_foreign_key(batch_op.f('fk_out_eia923__monthly_generation_fuel_by_generator_energy_source_plant_id_eia_core_eia__entity_generators'), 'core_eia__entity_generators', ['plant_id_eia', 'generator_id'], ['plant_id_eia', 'generator_id']) | ||
|
||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
with op.batch_alter_table('out_eia923__monthly_generation_fuel_by_generator_energy_source', schema=None) as batch_op: | ||
batch_op.drop_constraint(batch_op.f('fk_out_eia923__monthly_generation_fuel_by_generator_energy_source_plant_id_eia_core_eia__entity_generators'), type_='foreignkey') | ||
batch_op.create_foreign_key('fk_out_eia923__monthly_generation_fuel_by_generator_energy_source_plant_id_eia_core_eia860__scd_generators', 'core_eia860__scd_generators', ['plant_id_eia', 'generator_id', 'report_date'], ['plant_id_eia', 'generator_id', 'report_date']) | ||
|
||
with op.batch_alter_table('out_eia923__monthly_generation_fuel_by_generator', schema=None) as batch_op: | ||
batch_op.drop_constraint(batch_op.f('fk_out_eia923__monthly_generation_fuel_by_generator_plant_id_eia_core_eia__entity_generators'), type_='foreignkey') | ||
batch_op.drop_constraint(batch_op.f('fk_out_eia923__monthly_generation_fuel_by_generator_utility_id_eia_core_eia__entity_utilities'), type_='foreignkey') | ||
batch_op.create_foreign_key('fk_out_eia923__monthly_generation_fuel_by_generator_plant_id_eia_core_eia860__scd_generators', 'core_eia860__scd_generators', ['plant_id_eia', 'generator_id', 'report_date'], ['plant_id_eia', 'generator_id', 'report_date']) | ||
batch_op.create_foreign_key('fk_out_eia923__monthly_generation_fuel_by_generator_utility_id_eia_core_eia860__scd_utilities', 'core_eia860__scd_utilities', ['utility_id_eia', 'report_date'], ['utility_id_eia', 'report_date']) | ||
|
||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters