6d52f24ef3
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: multica-agent <github@multica.ai>
44 lines
1.7 KiB
Python
44 lines
1.7 KiB
Python
from __future__ import annotations
|
|
|
|
from datetime import datetime
|
|
from uuid import uuid4
|
|
|
|
from sqlalchemy import Boolean, DateTime, Index, Integer, String, Text
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from ..core.database import Base
|
|
from .base import utcnow
|
|
|
|
|
|
class DimensionItem(Base):
|
|
__tablename__ = "dimension_item"
|
|
__table_args__ = (
|
|
Index("idx_dimension_item_type", "dimension_type"),
|
|
Index("idx_dimension_item_parent", "parent_id"),
|
|
Index("idx_dimension_item_code", "code"),
|
|
Index("idx_dimension_item_enabled", "is_enabled"),
|
|
Index("idx_dimension_item_sort", "sort_order"),
|
|
)
|
|
|
|
id: Mapped[str] = mapped_column(
|
|
String(32),
|
|
primary_key=True,
|
|
default=lambda: uuid4().hex,
|
|
)
|
|
dimension_type: Mapped[str] = mapped_column(String(64), nullable=False, index=True)
|
|
code: Mapped[str] = mapped_column(String(128), nullable=False, index=True)
|
|
name: Mapped[str] = mapped_column(String(255), nullable=False)
|
|
parent_id: Mapped[str | None] = mapped_column(String(32), index=True)
|
|
description: Mapped[str | None] = mapped_column(Text)
|
|
is_enabled: Mapped[bool] = mapped_column(Boolean, default=True, index=True)
|
|
sort_order: Mapped[int] = mapped_column(Integer, default=0, index=True)
|
|
|
|
create_date: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=utcnow, index=True)
|
|
create_user: Mapped[str | None] = mapped_column(String(64), index=True)
|
|
update_date: Mapped[datetime] = mapped_column(
|
|
DateTime(timezone=True),
|
|
default=utcnow,
|
|
onupdate=utcnow,
|
|
)
|
|
update_user: Mapped[str | None] = mapped_column(String(64), index=True)
|