37 lines
1.4 KiB
Python
37 lines
1.4 KiB
Python
from datetime import datetime
|
|
|
|
from sqlalchemy import BigInteger, DateTime, ForeignKey, Integer, String, func
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.db.base import Base
|
|
|
|
|
|
class SchemeRecord(Base):
|
|
__tablename__ = "schemes"
|
|
|
|
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
|
|
scheme_id: Mapped[str] = mapped_column(String(32), unique=True, index=True, nullable=False)
|
|
|
|
source_upload_id: Mapped[str] = mapped_column(
|
|
String(32),
|
|
ForeignKey("uploads.upload_id", ondelete="RESTRICT"),
|
|
nullable=False,
|
|
index=True,
|
|
)
|
|
|
|
name: Mapped[str] = mapped_column(String(512), nullable=False)
|
|
status: Mapped[str] = mapped_column(String(32), nullable=False, default="draft")
|
|
current_version_number: Mapped[int] = mapped_column(Integer, nullable=False, default=1)
|
|
published_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
|
|
|
|
normalized_elements_count: Mapped[int] = mapped_column(Integer, nullable=False)
|
|
normalized_seats_count: Mapped[int] = mapped_column(Integer, nullable=False)
|
|
normalized_groups_count: Mapped[int] = mapped_column(Integer, nullable=False)
|
|
normalized_sectors_count: Mapped[int] = mapped_column(Integer, nullable=False)
|
|
|
|
created_at: Mapped[datetime] = mapped_column(
|
|
DateTime(timezone=True),
|
|
nullable=False,
|
|
server_default=func.now(),
|
|
)
|