Files
ai-contract-platform/backend/app/models/contract_template_version.py
T

29 lines
1.6 KiB
Python

from datetime import datetime, timezone
from typing import Any, Optional
from sqlalchemy import JSON, Boolean, DateTime, ForeignKey, String, Text
from sqlalchemy.orm import Mapped, mapped_column
from app.db import Base
class ContractTemplateVersion(Base):
__tablename__ = "contract_template_versions"
id: Mapped[str] = mapped_column(String(64), primary_key=True)
template_id: Mapped[str] = mapped_column(String(64), ForeignKey("contract_templates.id"), nullable=False, index=True)
tenant_id: Mapped[str] = mapped_column(String(64), nullable=False, index=True)
version_label: Mapped[str] = mapped_column(String(32), nullable=False)
change_summary: Mapped[Optional[str]] = mapped_column(String(500), nullable=True)
name: Mapped[str] = mapped_column(String(100), nullable=False)
contract_type: Mapped[Optional[str]] = mapped_column(String(50), nullable=True)
template_category: Mapped[Optional[str]] = mapped_column(String(64), nullable=True)
industry_category: Mapped[Optional[str]] = mapped_column(String(64), nullable=True)
description: Mapped[Optional[str]] = mapped_column(String(500), nullable=True)
content: Mapped[str] = mapped_column(Text, nullable=False)
variables_json: Mapped[Optional[list[dict[str, Any]]]] = mapped_column(JSON, nullable=True)
is_current: Mapped[bool] = mapped_column(Boolean, default=False)
created_by: Mapped[Optional[str]] = mapped_column(String(64), nullable=True)
created_by_name: Mapped[Optional[str]] = mapped_column(String(100), nullable=True)
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=lambda: datetime.now(timezone.utc))