-
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.
Merge branch 'release-0.2.0' into fix/hamed-decimal-formatting-bceid-…
…1529
- Loading branch information
Showing
83 changed files
with
1,346 additions
and
987 deletions.
There are no files selected for viewing
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
67 changes: 67 additions & 0 deletions
67
backend/lcfs/db/migrations/versions/2025-01-03-23-31_e883ad1f0f60.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,67 @@ | ||
"""Rename Reassessed | ||
Revision ID: e883ad1f0f60 | ||
Revises: 9329e38396e1 | ||
Create Date: 2025-01-03 23:31:19.098618 | ||
""" | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
from alembic_postgresql_enum import TableReference | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "e883ad1f0f60" | ||
down_revision = "9329e38396e1" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.sync_enum_values( | ||
"public", | ||
"compliancereportstatusenum", | ||
[ | ||
"Draft", | ||
"Submitted", | ||
"Recommended_by_analyst", | ||
"Recommended_by_manager", | ||
"Assessed", | ||
"Reassessed", | ||
], | ||
[ | ||
TableReference( | ||
table_schema="public", | ||
table_name="compliance_report_status", | ||
column_name="status", | ||
) | ||
], | ||
enum_values_to_rename=[("ReAssessed", "Reassessed")], | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.sync_enum_values( | ||
"public", | ||
"compliancereportstatusenum", | ||
[ | ||
"Draft", | ||
"Submitted", | ||
"Recommended_by_analyst", | ||
"Recommended_by_manager", | ||
"Assessed", | ||
"ReAssessed", | ||
], | ||
[ | ||
TableReference( | ||
table_schema="public", | ||
table_name="compliance_report_status", | ||
column_name="status", | ||
) | ||
], | ||
enum_values_to_rename=[("Reassessed", "ReAssessed")], | ||
) | ||
# ### end Alembic commands ### |
37 changes: 37 additions & 0 deletions
37
backend/lcfs/db/migrations/versions/2025-01-04-13-24_bfa7bbb1eea3.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,37 @@ | ||
"""Update fuel type name | ||
Revision ID: bfa7bbb1eea3 | ||
Revises: 9329e38396e1 | ||
Create Date: 2025-01-03 13:24:19.525006 | ||
""" | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "bfa7bbb1eea3" | ||
down_revision = "e883ad1f0f60" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
# Update fuel type name | ||
op.execute(""" | ||
UPDATE fuel_type | ||
SET fuel_type = 'Other diesel fuel', | ||
provision_1_id = 3 -- Change from prescribed (1) to default (3) | ||
WHERE fuel_type = 'Other diesel'; | ||
""") | ||
|
||
|
||
def downgrade() -> None: | ||
# Revert fuel type name update | ||
op.execute(""" | ||
UPDATE fuel_type | ||
SET fuel_type = 'Other diesel', | ||
provision_1_id = 1 -- Change from default (3) to prescribed (1) | ||
WHERE fuel_type = 'Other diesel fuel'; | ||
""") | ||
|
37 changes: 37 additions & 0 deletions
37
backend/lcfs/db/migrations/versions/2025-01-05-18-43_ca7200152130.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,37 @@ | ||
"""Add is_legacy to fuel_type | ||
Revision ID: ca7200152130 | ||
Revises: bfa7bbb1eea3 | ||
Create Date: 2025-01-05 18:43:43.638740 | ||
""" | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "ca7200152130" | ||
down_revision = "bfa7bbb1eea3" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.add_column( | ||
"fuel_type", | ||
sa.Column( | ||
"is_legacy", | ||
sa.Boolean(), | ||
server_default=sa.text("FALSE"), | ||
nullable=False, | ||
comment="Indicates if the fuel type is legacy and should not be used for new reports", | ||
), | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_column("fuel_type", "is_legacy") | ||
# ### end Alembic commands ### |
125 changes: 125 additions & 0 deletions
125
backend/lcfs/db/migrations/versions/2025-01-06-19-01_94306eca5261.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,125 @@ | ||
""" | ||
Add is_legacy to Provisions and insert data | ||
Revision ID: 94306eca5261 | ||
Revises: ca7200152130 | ||
Create Date: 2025-01-06 19:01:53.418638 | ||
""" | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "94306eca5261" | ||
down_revision = "ca7200152130" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
# 1) Add the new column | ||
op.add_column( | ||
"provision_of_the_act", | ||
sa.Column( | ||
"is_legacy", | ||
sa.Boolean(), | ||
server_default=sa.text("FALSE"), | ||
nullable=False, | ||
comment="Indicates if the provision is legacy and should not be used for new reports", | ||
), | ||
) | ||
|
||
# 2) Insert or update data to populate is_legacy, etc. | ||
# For demonstration, we'll use bulk_insert here. If your table already | ||
# has data, you might prefer an UPDATE or a combination of both. | ||
provision_of_the_act = sa.Table( | ||
"provision_of_the_act", | ||
sa.MetaData(), | ||
sa.Column("provision_of_the_act_id", sa.Integer, primary_key=True), | ||
sa.Column("name", sa.String), | ||
sa.Column("description", sa.String), | ||
sa.Column("create_user", sa.String), | ||
sa.Column("update_user", sa.String), | ||
sa.Column("display_order", sa.Integer), | ||
sa.Column("effective_date", sa.Date), | ||
sa.Column("effective_status", sa.Boolean), | ||
sa.Column("expiration_date", sa.Date), | ||
sa.Column("is_legacy", sa.Boolean), | ||
) | ||
|
||
op.bulk_insert( | ||
provision_of_the_act, | ||
[ | ||
{ | ||
"name": "Prescribed carbon intensity - Section 6 (5) (a)", | ||
"description": "Prescribed carbon intensity - Section 6 (5) (a)", | ||
"create_user": "no_user", | ||
"update_user": "no_user", | ||
"display_order": None, | ||
"effective_date": None, | ||
"effective_status": True, | ||
"expiration_date": None, | ||
"is_legacy": True, | ||
}, | ||
{ | ||
"name": "Prescribed carbon intensity - Section 6 (5) (b)", | ||
"description": "Prescribed carbon intensity - Section 6 (5) (b)", | ||
"create_user": "no_user", | ||
"update_user": "no_user", | ||
"display_order": None, | ||
"effective_date": None, | ||
"effective_status": True, | ||
"expiration_date": None, | ||
"is_legacy": True, | ||
}, | ||
{ | ||
"name": "Approved fuel code - Section 6 (5) (c)", | ||
"description": "Approved fuel code - Section 6 (5) (c)", | ||
"create_user": "no_user", | ||
"update_user": "no_user", | ||
"display_order": None, | ||
"effective_date": None, | ||
"effective_status": True, | ||
"expiration_date": None, | ||
"is_legacy": True, | ||
}, | ||
{ | ||
"name": "Default Carbon Intensity Value - Section 6 (5) (d) (i)", | ||
"description": "Default Carbon Intensity Value - Section 6 (5) (d) (i)", | ||
"create_user": "no_user", | ||
"update_user": "no_user", | ||
"display_order": None, | ||
"effective_date": None, | ||
"effective_status": True, | ||
"expiration_date": None, | ||
"is_legacy": True, | ||
}, | ||
{ | ||
"name": "GHGenius modelled - Section 6 (5) (d) (ii) (A)", | ||
"description": "GHGenius modelled - Section 6 (5) (d) (ii) (A)", | ||
"create_user": "no_user", | ||
"update_user": "no_user", | ||
"display_order": None, | ||
"effective_date": None, | ||
"effective_status": True, | ||
"expiration_date": None, | ||
"is_legacy": True, | ||
}, | ||
{ | ||
"name": "Alternative Method - Section 6 (5) (d) (ii) (B)", | ||
"description": "Alternative Method - Section 6 (5) (d) (ii) (B)", | ||
"create_user": "no_user", | ||
"update_user": "no_user", | ||
"display_order": None, | ||
"effective_date": None, | ||
"effective_status": True, | ||
"expiration_date": None, | ||
"is_legacy": True, | ||
}, | ||
], | ||
) | ||
|
||
|
||
def downgrade() -> None: | ||
# Remove is_legacy column. (Data removal is optional or up to you.) | ||
op.drop_column("provision_of_the_act", "is_legacy") |
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
Oops, something went wrong.