-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
179 additions
and
6 deletions.
There are no files selected for viewing
95 changes: 95 additions & 0 deletions
95
backend/lcfs/db/migrations/versions/2024-12-09-19-31_7ae38a8413ab.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,95 @@ | ||
"""Update Fuel Types measured in volume to be other-uses | ||
Revision ID: 7ae38a8413ab | ||
Revises: 26ab15f8ab18 | ||
Create Date: 2024-12-09 19:31:18.199089 | ||
""" | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
from datetime import datetime | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "7ae38a8413ab" | ||
down_revision = "26ab15f8ab18" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
current_time = datetime.now() | ||
|
||
# Update the `other_uses_fossil_derived` field for all specified fuel types | ||
op.execute( | ||
f""" | ||
UPDATE fuel_type | ||
SET other_uses_fossil_derived = true, | ||
update_date = '{current_time}', | ||
update_user = 'no_user' | ||
WHERE fuel_type IN ( | ||
'Alternative jet fuel', | ||
'Biodiesel', | ||
'Ethanol', | ||
'HDRD', | ||
'Renewable gasoline', | ||
'Renewable naphtha' | ||
) | ||
""" | ||
) | ||
|
||
# Update the `other_uses_fossil_derived` field for all specified fuel types | ||
op.execute( | ||
f""" | ||
UPDATE fuel_type | ||
SET other_uses_fossil_derived = false, | ||
update_date = '{current_time}', | ||
update_user = 'no_user' | ||
WHERE fuel_type IN ( | ||
'CNG', | ||
'Electricity', | ||
'Hydrogen', | ||
'LNG', | ||
'Propane' | ||
) | ||
""" | ||
) | ||
|
||
|
||
def downgrade() -> None: | ||
current_time = datetime.now() | ||
|
||
# Revert the `other_uses_fossil_derived` field to false for the first set of fuel types | ||
op.execute( | ||
f""" | ||
UPDATE fuel_type | ||
SET other_uses_fossil_derived = false, | ||
update_date = '{current_time}', | ||
update_user = 'no_user' | ||
WHERE fuel_type IN ( | ||
'Alternative jet fuel', | ||
'Biodiesel', | ||
'Ethanol', | ||
'HDRD', | ||
'Renewable gasoline', | ||
'Renewable naphtha' | ||
) | ||
""" | ||
) | ||
|
||
# Revert the `other_uses_fossil_derived` field to true for the second set of fuel types | ||
op.execute( | ||
f""" | ||
UPDATE fuel_type | ||
SET other_uses_fossil_derived = true, | ||
update_date = '{current_time}', | ||
update_user = 'no_user' | ||
WHERE fuel_type IN ( | ||
'CNG', | ||
'Electricity', | ||
'Hydrogen', | ||
'LNG', | ||
'Propane' | ||
) | ||
""" | ||
) |
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