Skip to content

Commit a6c3389

Browse files
authored
Merge pull request #3985 from bcgov/release
Release v1.2.7
2 parents 844f583 + f33d058 commit a6c3389

File tree

80 files changed

+4900
-267
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+4900
-267
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""Add Gigajoules to quantity units enum.
2+
3+
Revision ID: e3b7a9d4c2f1
4+
Revises: 3d7b65a9d2ef
5+
Create Date: 2026-02-19 10:00:00.000000
6+
"""
7+
8+
from alembic import op
9+
10+
# revision identifiers, used by Alembic.
11+
revision = "e3b7a9d4c2f1"
12+
down_revision = "3d7b65a9d2ef"
13+
branch_labels = None
14+
depends_on = None
15+
16+
17+
def upgrade() -> None:
18+
with op.get_context().autocommit_block():
19+
op.execute("ALTER TYPE quantityunitsenum ADD VALUE IF NOT EXISTS 'Gigajoules'")
20+
21+
22+
def downgrade() -> None:
23+
# PostgreSQL does not support removing enum values in-place.
24+
pass
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"""Add active flag to compliance report charging equipment
2+
3+
Revision ID: b1234567890c
4+
Revises: e3b7a9d4c2f1
5+
Create Date: 2026-03-01 12:00:00.000000
6+
"""
7+
8+
from alembic import op
9+
import sqlalchemy as sa
10+
11+
# revision identifiers, used by Alembic.
12+
revision = "b1234567890c"
13+
down_revision = "e3b7a9d4c2f1"
14+
branch_labels = None
15+
depends_on = None
16+
17+
18+
def upgrade() -> None:
19+
op.add_column(
20+
"compliance_report_charging_equipment",
21+
sa.Column(
22+
"is_active",
23+
sa.Boolean(),
24+
nullable=False,
25+
server_default=sa.true(),
26+
comment="Indicates whether the reporting row is active for compliance",
27+
),
28+
)
29+
30+
op.execute(
31+
"""
32+
UPDATE compliance_report_charging_equipment
33+
SET is_active = TRUE
34+
WHERE is_active IS NULL
35+
"""
36+
)
37+
38+
39+
def downgrade() -> None:
40+
op.drop_column("compliance_report_charging_equipment", "is_active")
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
"""Create credit market audit log table
2+
3+
Revision ID: 8e9f1a2b3c4d
4+
Revises: b1234567890c
5+
Create Date: 2026-02-11 10:30:00.000000
6+
7+
"""
8+
9+
import sqlalchemy as sa
10+
from alembic import op
11+
12+
# revision identifiers, used by Alembic.
13+
revision = "8e9f1a2b3c4d"
14+
down_revision = "b1234567890c"
15+
branch_labels = None
16+
depends_on = None
17+
18+
19+
def upgrade() -> None:
20+
op.create_table(
21+
"credit_market_audit_log",
22+
sa.Column(
23+
"credit_market_audit_log_id",
24+
sa.Integer(),
25+
autoincrement=True,
26+
nullable=False,
27+
comment="Unique identifier for each credit market audit log entry.",
28+
),
29+
sa.Column(
30+
"organization_id",
31+
sa.Integer(),
32+
nullable=False,
33+
comment="Organization associated with the credit market listing change.",
34+
),
35+
sa.Column(
36+
"credits_to_sell",
37+
sa.Integer(),
38+
nullable=False,
39+
server_default=sa.text("0"),
40+
comment="Credits to sell at the time of the change.",
41+
),
42+
sa.Column(
43+
"credit_market_is_seller",
44+
sa.Boolean(),
45+
nullable=False,
46+
server_default=sa.text("false"),
47+
comment="Whether the organization was marked as seller.",
48+
),
49+
sa.Column(
50+
"credit_market_is_buyer",
51+
sa.Boolean(),
52+
nullable=False,
53+
server_default=sa.text("false"),
54+
comment="Whether the organization was marked as buyer.",
55+
),
56+
sa.Column(
57+
"contact_person",
58+
sa.String(length=500),
59+
nullable=True,
60+
comment="Credit market contact person name.",
61+
),
62+
sa.Column(
63+
"phone",
64+
sa.String(length=50),
65+
nullable=True,
66+
comment="Credit market contact phone.",
67+
),
68+
sa.Column(
69+
"email",
70+
sa.String(length=255),
71+
nullable=True,
72+
comment="Credit market contact email.",
73+
),
74+
sa.Column(
75+
"changed_by",
76+
sa.String(length=255),
77+
nullable=True,
78+
comment="BCeID/IDIR username that performed the listing change.",
79+
),
80+
sa.Column(
81+
"create_date",
82+
sa.TIMESTAMP(timezone=True),
83+
server_default=sa.text("now()"),
84+
nullable=True,
85+
comment="Date and time (UTC) when the physical record was created in the database.",
86+
),
87+
sa.Column(
88+
"update_date",
89+
sa.TIMESTAMP(timezone=True),
90+
server_default=sa.text("now()"),
91+
nullable=True,
92+
comment="Date and time (UTC) when the physical record was updated in the database. It will be the same as the create_date until the record is first updated after creation.",
93+
),
94+
sa.PrimaryKeyConstraint(
95+
"credit_market_audit_log_id", name=op.f("pk_credit_market_audit_log")
96+
),
97+
sa.ForeignKeyConstraint(
98+
["organization_id"],
99+
["organization.organization_id"],
100+
name=op.f("fk_credit_market_audit_log_organization_id_organization"),
101+
),
102+
comment="Captures historical snapshots of credit trading market listings after each change.",
103+
)
104+
105+
op.create_index(
106+
"idx_credit_market_audit_log_create_date",
107+
"credit_market_audit_log",
108+
["create_date"],
109+
unique=False,
110+
)
111+
op.create_index(
112+
"idx_credit_market_audit_log_changed_by",
113+
"credit_market_audit_log",
114+
["changed_by"],
115+
unique=False,
116+
)
117+
118+
119+
def downgrade() -> None:
120+
op.drop_index(
121+
"idx_credit_market_audit_log_changed_by",
122+
table_name="credit_market_audit_log",
123+
)
124+
op.drop_index(
125+
"idx_credit_market_audit_log_create_date",
126+
table_name="credit_market_audit_log",
127+
)
128+
op.drop_table("credit_market_audit_log")
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
"""Alter unique constraints on Charging site
2+
3+
Revision ID: 84d7cf6d1940
4+
Revises: 8e9f1a2b3c4d
5+
Create Date: 2026-03-03 11:30:47.227193
6+
7+
"""
8+
9+
import sqlalchemy as sa
10+
from alembic import op
11+
from alembic_postgresql_enum import TableReference
12+
from sqlalchemy.dialects import postgresql
13+
14+
# revision identifiers, used by Alembic.
15+
revision = "84d7cf6d1940"
16+
down_revision = "8e9f1a2b3c4d"
17+
branch_labels = None
18+
depends_on = None
19+
20+
21+
def upgrade() -> None:
22+
op.drop_index(
23+
op.f("idx_charging_equipment_charging_site_id"),
24+
table_name="charging_equipment",
25+
if_exists=True,
26+
)
27+
op.drop_index(
28+
op.f("idx_charging_site_site_code"), table_name="charging_site", if_exists=True
29+
)
30+
op.drop_constraint(
31+
op.f("uq_charging_site_org_name"),
32+
"charging_site",
33+
type_="unique",
34+
if_exists=True,
35+
)
36+
op.drop_constraint(
37+
op.f("uq_charging_site_site_code"),
38+
"charging_site",
39+
type_="unique",
40+
if_exists=True,
41+
)
42+
op.create_index(
43+
op.f("idx_charging_site_site_code"),
44+
"charging_site",
45+
["site_code"],
46+
unique=False,
47+
)
48+
op.create_unique_constraint(
49+
"uq_charging_site_id_version", "charging_site", ["charging_site_id", "version"]
50+
)
51+
op.create_unique_constraint(
52+
"uq_charging_site_org_name",
53+
"charging_site",
54+
["organization_id", "site_name", "site_code", "version"],
55+
)
56+
57+
58+
def downgrade() -> None:
59+
op.drop_constraint(
60+
"uq_charging_site_org_name", "charging_site", type_="unique", if_exists=True
61+
)
62+
op.drop_constraint(
63+
"uq_charging_site_id_version", "charging_site", type_="unique", if_exists=True
64+
)
65+
op.drop_index(
66+
op.f("idx_charging_site_site_code"), table_name="charging_site", if_exists=True
67+
)
68+
op.create_index(
69+
op.f("idx_charging_site_site_code"),
70+
"charging_site",
71+
["site_code"],
72+
unique=False,
73+
)
74+
op.create_unique_constraint(
75+
op.f("uq_charging_site_site_code"), "charging_site", ["site_code"]
76+
)
77+
op.create_unique_constraint(
78+
"uq_charging_site_org_name",
79+
"charging_site",
80+
["organization_id", "site_name", "site_code"],
81+
)
82+
op.create_index(
83+
op.f("idx_charging_equipment_charging_site_id"),
84+
"charging_equipment",
85+
["charging_site_id"],
86+
unique=False,
87+
)

backend/lcfs/db/models/compliance/ChargingSite.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,18 @@ class ChargingSite(BaseModel, Auditable, Versioning):
4141

4242
__tablename__ = "charging_site"
4343
__table_args__ = (
44-
UniqueConstraint("site_code"),
4544
UniqueConstraint(
4645
"organization_id",
4746
"site_name",
47+
"site_code",
48+
"version",
4849
name="uq_charging_site_org_name",
4950
),
51+
UniqueConstraint(
52+
"charging_site_id",
53+
"version",
54+
name="uq_charging_site_id_version",
55+
),
5056
{"comment": "Charging sites"},
5157
)
5258

backend/lcfs/db/models/compliance/ComplianceReport.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class QuantityUnitsEnum(enum.Enum):
3838
Litres = "L"
3939
Kilograms = "kg"
4040
Kilowatt_hour = "kWh"
41+
Gigajoules = "Gj"
4142
Cubic_metres = "m³"
4243

4344

backend/lcfs/db/models/compliance/ComplianceReportChargingEquipment.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
Double,
1111
DateTime,
1212
UniqueConstraint,
13+
Boolean,
1314
)
1415
from sqlalchemy.orm import relationship
1516
from datetime import datetime
@@ -116,6 +117,13 @@ class ComplianceReportChargingEquipment(BaseModel, Auditable):
116117
nullable=True,
117118
comment="Optional notes about compliance for this association",
118119
)
120+
is_active = Column(
121+
Boolean,
122+
nullable=False,
123+
default=True,
124+
server_default="true",
125+
comment="Indicates whether the association is active for reporting",
126+
)
119127

120128
# Relationships
121129
charging_equipment = relationship(

backend/lcfs/db/models/fuel/FuelType.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class QuantityUnitsEnum(enum.Enum):
1212
Litres = "L"
1313
Kilograms = "kg"
1414
Kilowatt_hour = "kWh"
15+
Gigajoules = "Gj"
1516
Cubic_metres = "m³"
1617

1718

0 commit comments

Comments
 (0)