from datetime import datetime from decimal import Decimal from sqlalchemy import BigInteger, DateTime, Numeric, String, func from sqlalchemy.orm import Mapped, mapped_column from app.db.base import Base class SchemeVersionPricingCategoryRecord(Base): __tablename__ = "scheme_version_pricing_categories" id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True) snapshot_category_id: Mapped[str] = mapped_column(String(32), unique=True, index=True, nullable=False) scheme_id: Mapped[str] = mapped_column(String(32), nullable=False) scheme_version_id: Mapped[str] = mapped_column(String(32), index=True, nullable=False) source_pricing_category_id: Mapped[str | None] = mapped_column(String(32), nullable=True) name: Mapped[str] = mapped_column(String(255), nullable=False) code: Mapped[str | None] = mapped_column(String(128), nullable=True) created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False, server_default=func.now()) class SchemeVersionPriceRuleRecord(Base): __tablename__ = "scheme_version_price_rules" id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True) snapshot_price_rule_id: Mapped[str] = mapped_column(String(32), unique=True, index=True, nullable=False) scheme_id: Mapped[str] = mapped_column(String(32), nullable=False) scheme_version_id: Mapped[str] = mapped_column(String(32), index=True, nullable=False) source_price_rule_id: Mapped[str | None] = mapped_column(String(32), nullable=True) snapshot_category_id: Mapped[str | None] = mapped_column(String(32), nullable=True) target_type: Mapped[str] = mapped_column(String(32), nullable=False) target_ref: Mapped[str] = mapped_column(String(128), nullable=False) amount: Mapped[Decimal] = mapped_column(Numeric(12, 2), nullable=False) currency: Mapped[str] = mapped_column(String(8), nullable=False) created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False, server_default=func.now())