From 68cd09114c8607a21f664c478f8047e1f9be62f3 Mon Sep 17 00:00:00 2001 From: Daniel Haselhan Date: Wed, 18 Dec 2024 13:27:34 -0800 Subject: [PATCH] fix: Add Marine Use * Add Marine end use * Link marine end use to Electricity/Diesel --- .../versions/2024-12-18-19-43_909969082dfb.py | 48 +++++++++++++++++++ .../db/seeders/common/seed_fuel_data.json | 12 +++++ 2 files changed, 60 insertions(+) create mode 100644 backend/lcfs/db/migrations/versions/2024-12-18-19-43_909969082dfb.py diff --git a/backend/lcfs/db/migrations/versions/2024-12-18-19-43_909969082dfb.py b/backend/lcfs/db/migrations/versions/2024-12-18-19-43_909969082dfb.py new file mode 100644 index 000000000..9da3b2bb9 --- /dev/null +++ b/backend/lcfs/db/migrations/versions/2024-12-18-19-43_909969082dfb.py @@ -0,0 +1,48 @@ +"""Add Marine End Use + +Revision ID: 909969082dfb +Revises: 851e09cf8661 +Create Date: 2024-12-18 19:43:06.680781 + +""" + +import sqlalchemy as sa +from alembic import op + +# revision identifiers, used by Alembic. +revision = "909969082dfb" +down_revision = "851e09cf8661" +branch_labels = None +depends_on = None + + +def upgrade() -> None: + op.execute( + """ + INSERT INTO "end_use_type" ("type", "intended_use", "create_user", "update_user") VALUES ('Marine', 't', 'no_user', 'no_user'); + """ + ) + + op.execute( + """ + INSERT INTO "public"."energy_effectiveness_ratio" ("fuel_category_id", "fuel_type_id", "end_use_type_id", "ratio", "create_user", "update_user", "effective_status") VALUES (2, 3, (SELECT end_use_type_id FROM "end_use_type" WHERE "type" = 'Marine'), 2.5, 'no_user', 'no_user', 't'); + """ + ) + + +def downgrade() -> None: + # Remove the inserted energy_effectiveness_ratio entry + op.execute( + """ + DELETE FROM "public"."energy_effectiveness_ratio" + WHERE end_use_type_id = (SELECT end_use_type_id FROM "end_use_type" WHERE "type" = 'Marine'); + """ + ) + + # Remove the inserted end_use_type entry + op.execute( + """ + DELETE FROM "end_use_type" + WHERE "type" = 'Marine'; + """ + ) diff --git a/backend/lcfs/db/seeders/common/seed_fuel_data.json b/backend/lcfs/db/seeders/common/seed_fuel_data.json index c80c5f972..a527f5cb9 100644 --- a/backend/lcfs/db/seeders/common/seed_fuel_data.json +++ b/backend/lcfs/db/seeders/common/seed_fuel_data.json @@ -377,6 +377,11 @@ "end_use_type_id": 23, "type": "Other (i.e. road transportation)", "intended_use": true + }, + { + "end_use_type_id": 24, + "type": "Marine", + "intended_use": true } ], "unit_of_measures": [ @@ -686,6 +691,13 @@ "fuel_type_id": 7, "end_use_type_id": 23, "ratio": 0.9 + }, + { + "eer_id": 31, + "fuel_category_id": 2, + "fuel_type_id": 3, + "end_use_type_id": 24, + "ratio": 2.5 } ], "energy_densities": [