Skip to content

Commit

Permalink
Cleanup UQs and Add Migration
Browse files Browse the repository at this point in the history
  • Loading branch information
dhaselhan committed Dec 19, 2024
1 parent b6d0355 commit bd0347b
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""Add UQ to TCI
Revision ID: ab04810d4d7c
Revises: 851e09cf8661
Create Date: 2024-12-19 23:46:37.505166
"""

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "ab04810d4d7c"
down_revision = "851e09cf8661"
branch_labels = None
depends_on = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_unique_constraint(
"uq_target_carbon_intensity_compliance_fuel",
"target_carbon_intensity",
["compliance_period_id", "fuel_category_id"],
)
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(
"uq_target_carbon_intensity_compliance_fuel",
"target_carbon_intensity",
type_="unique",
)
# ### end Alembic commands ###
1 change: 0 additions & 1 deletion backend/lcfs/db/models/admin_adjustment/AdminAdjustment.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
class AdminAdjustment(BaseModel, Auditable, EffectiveDates):
__tablename__ = "admin_adjustment"
__table_args__ = (
UniqueConstraint("admin_adjustment_id"),
{"comment": "Goverment to organization compliance units admin_adjustment"},
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
class AdminAdjustmentHistory(BaseModel, Auditable, EffectiveDates):
__tablename__ = "admin_adjustment_history"
__table_args__ = (
UniqueConstraint("admin_adjustment_history_id"),
{"comment": "History record for admin_adjustment status change."},
)

Expand Down
3 changes: 1 addition & 2 deletions backend/lcfs/db/models/comment/InternalComment.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
class InternalComment(BaseModel, Auditable):
__tablename__ = "internal_comment"
__table_args__ = (
UniqueConstraint("internal_comment_id"),
{"comment": "Stores internal comments with scope and related metadata."},
)

Expand Down Expand Up @@ -42,4 +41,4 @@ class InternalComment(BaseModel, Auditable):
)
compliance_report_internal_comments = relationship(
"ComplianceReportInternalComment", back_populates="internal_comment"
)
)
1 change: 0 additions & 1 deletion backend/lcfs/db/models/document/Document.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
class Document(BaseModel, Auditable):
__tablename__ = "document"
__table_args__ = (
UniqueConstraint("document_id"),
{"comment": "Main document table for storing base document information"},
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
class InitiativeAgreement(BaseModel, Auditable, EffectiveDates):
__tablename__ = "initiative_agreement"
__table_args__ = (
UniqueConstraint("initiative_agreement_id"),
{"comment": "Goverment to organization compliance units initiative agreement"},
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
class InitiativeAgreementHistory(BaseModel, Auditable, EffectiveDates):
__tablename__ = "initiative_agreement_history"
__table_args__ = (
UniqueConstraint("initiative_agreement_history_id"),
{"comment": "History record for initiative agreement status change."},
)

Expand Down
1 change: 0 additions & 1 deletion backend/lcfs/db/models/transaction/Transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class TransactionActionEnum(enum.Enum):
class Transaction(BaseModel, Auditable, EffectiveDates):
__tablename__ = "transaction"
__table_args__ = (
UniqueConstraint("transaction_id"),
{
"comment": "Contains a list of all of the government to organization and Organization to Organization transaction."
},
Expand Down
1 change: 0 additions & 1 deletion backend/lcfs/db/models/transfer/Transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class TransferRecommendationEnum(enum.Enum):
class Transfer(BaseModel, Auditable, EffectiveDates):
__tablename__ = "transfer"
__table_args__ = (
UniqueConstraint("transfer_id"),
{"comment": "Records of tranfer from Organization to Organization"},
)

Expand Down
5 changes: 1 addition & 4 deletions backend/lcfs/db/models/transfer/TransferCategory.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ class TransferCategoryEnum(enum.Enum):

class TransferCategory(BaseModel, Auditable, EffectiveDates):
__tablename__ = "transfer_category"
__table_args__ = (
UniqueConstraint("transfer_category_id"),
{"comment": "Transfer Category"},
)
__table_args__ = ({"comment": "Transfer Category"},)

transfer_category_id = Column(
Integer,
Expand Down

0 comments on commit bd0347b

Please sign in to comment.