feat: Implement SQLAlchemy enum helper and normalize enum values in database initialization
This commit is contained in:
@@ -3,9 +3,9 @@ from __future__ import annotations
|
||||
from datetime import datetime
|
||||
from typing import TYPE_CHECKING, List
|
||||
|
||||
from .enums import MiningOperationType
|
||||
from .enums import MiningOperationType, sql_enum
|
||||
|
||||
from sqlalchemy import DateTime, Enum as SQLEnum, ForeignKey, Integer, String, Text
|
||||
from sqlalchemy import DateTime, ForeignKey, Integer, String, Text
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from sqlalchemy.sql import func
|
||||
|
||||
@@ -16,8 +16,6 @@ if TYPE_CHECKING: # pragma: no cover
|
||||
from .pricing_settings import PricingSettings
|
||||
|
||||
|
||||
|
||||
|
||||
class Project(Base):
|
||||
"""Top-level mining project grouping multiple scenarios."""
|
||||
|
||||
@@ -27,7 +25,7 @@ class Project(Base):
|
||||
name: Mapped[str] = mapped_column(String(255), nullable=False, unique=True)
|
||||
location: Mapped[str | None] = mapped_column(String(255), nullable=True)
|
||||
operation_type: Mapped[MiningOperationType] = mapped_column(
|
||||
SQLEnum(MiningOperationType, name="miningoperationtype", create_type=False),
|
||||
sql_enum(MiningOperationType, name="miningoperationtype"),
|
||||
nullable=False,
|
||||
default=MiningOperationType.OTHER,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user