File size: 957 Bytes
57cf043
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86c402d
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from sqlalchemy import (
    Boolean,
    ForeignKey,
    Integer,
    String,
)
from sqlalchemy.orm import Mapped, relationship, mapped_column

from components.dbo.models.base import Base

class Dataset(Base):
    """
    Сущность, которая хранит информацию о датасете.
    """

    __tablename__ = "dataset"

    name: Mapped[str] = mapped_column(String, unique=True)
    is_draft: Mapped[bool] = mapped_column(Boolean, default=True)
    is_active: Mapped[bool] = mapped_column(Boolean, default=True)
    previous_dataset_id: Mapped[int] = mapped_column(Integer, ForeignKey("dataset.id"), nullable=True)

    documents: Mapped[list["DatasetDocument"]] = relationship(
        "DatasetDocument", back_populates="dataset",
        cascade="all, delete-orphan"
    )

    entities: Mapped[list["EntityModel"]] = relationship(
        "EntityModel", back_populates="dataset",
        cascade="all, delete-orphan"
    )