from datetime import datetime from sqlalchemy import BigInteger, DateTime, Integer, String, ForeignKey from sqlalchemy.dialects.mysql import LONGTEXT from sqlalchemy.orm import Mapped, mapped_column from alien_database.base import Base, AuditMixin class ContractDocument(Base, AuditMixin): __tablename__ = "contract_document" id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True) bundle_id: Mapped[int] = mapped_column(BigInteger, ForeignKey("contract_bundle.id"), index=True) contract_type: Mapped[str] = mapped_column(String(50)) contract_name: Mapped[str] = mapped_column(String(100)) is_primary: Mapped[int] = mapped_column(Integer, default=0) status: Mapped[int] = mapped_column(Integer, default=0) sign_flow_id: Mapped[str] = mapped_column(String(64), unique=True) file_id: Mapped[str] = mapped_column(String(64)) template_url: Mapped[str] = mapped_column(LONGTEXT) sign_url: Mapped[str] = mapped_column(LONGTEXT) download_url: Mapped[str] = mapped_column(LONGTEXT) signing_time: Mapped[datetime | None] = mapped_column(DateTime, nullable=True) effective_time: Mapped[datetime | None] = mapped_column(DateTime, nullable=True) expiry_time: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)