28 lines
1.1 KiB
Python
28 lines
1.1 KiB
Python
"""真理节点模型"""
|
|
from .base import Base
|
|
from .types import JSONB
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
from sqlalchemy import BigInteger, VARCHAR, Integer, ForeignKey
|
|
from typing import Optional
|
|
|
|
|
|
class TruthNode(Base):
|
|
__tablename__ = "truth_nodes"
|
|
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
|
node_type: Mapped[str] = mapped_column(VARCHAR(50), nullable=False)
|
|
parent_id: Mapped[Optional[int]] = mapped_column(
|
|
BigInteger, ForeignKey("truth_nodes.id"), nullable=True
|
|
)
|
|
project_id: Mapped[Optional[int]] = mapped_column(BigInteger, nullable=True)
|
|
signal_id: Mapped[Optional[int]] = mapped_column(
|
|
BigInteger, ForeignKey("signals.id"), nullable=True, index=True
|
|
)
|
|
created_by: Mapped[int] = mapped_column(
|
|
BigInteger, ForeignKey("users.id"), nullable=False
|
|
)
|
|
title: Mapped[str] = mapped_column(VARCHAR(500), nullable=False)
|
|
content: Mapped[dict] = mapped_column(JSONB, nullable=False)
|
|
version: Mapped[int] = mapped_column(Integer, nullable=False, default=1)
|
|
status: Mapped[str] = mapped_column(VARCHAR(50), nullable=False)
|