You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
2.0 KiB
Python
55 lines
2.0 KiB
Python
from __future__ import annotations
|
|
|
|
from sqlalchemy import ForeignKey, Integer, JSON, String, Text, UniqueConstraint
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from admin_app.db.models.base import AdminTimestampedModel
|
|
from admin_app.db.models.tool_draft import ToolLifecycleStatusType
|
|
from shared.contracts import ToolLifecycleStatus
|
|
|
|
|
|
class ToolMetadata(AdminTimestampedModel):
|
|
__tablename__ = "tool_metadata"
|
|
__table_args__ = (
|
|
UniqueConstraint(
|
|
"tool_name",
|
|
"version_number",
|
|
name="uq_tool_metadata_tool_name_version_number",
|
|
),
|
|
)
|
|
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
|
metadata_id: Mapped[str] = mapped_column(String(120), unique=True, index=True, nullable=False)
|
|
draft_id: Mapped[int] = mapped_column(
|
|
Integer,
|
|
ForeignKey("tool_drafts.id"),
|
|
nullable=False,
|
|
index=True,
|
|
)
|
|
tool_version_id: Mapped[int] = mapped_column(
|
|
Integer,
|
|
ForeignKey("tool_versions.id"),
|
|
nullable=False,
|
|
unique=True,
|
|
index=True,
|
|
)
|
|
tool_name: Mapped[str] = mapped_column(String(64), index=True, nullable=False)
|
|
display_name: Mapped[str] = mapped_column(String(120), nullable=False)
|
|
domain: Mapped[str] = mapped_column(String(40), index=True, nullable=False)
|
|
description: Mapped[str] = mapped_column(Text, nullable=False)
|
|
parameters_json: Mapped[list[dict]] = mapped_column(JSON, nullable=False, default=list)
|
|
version_number: Mapped[int] = mapped_column(Integer, nullable=False)
|
|
status: Mapped[ToolLifecycleStatus] = mapped_column(
|
|
ToolLifecycleStatusType(),
|
|
nullable=False,
|
|
default=ToolLifecycleStatus.DRAFT,
|
|
index=True,
|
|
)
|
|
author_staff_account_id: Mapped[int] = mapped_column(
|
|
Integer,
|
|
ForeignKey("staff_accounts.id"),
|
|
nullable=False,
|
|
index=True,
|
|
)
|
|
author_display_name: Mapped[str] = mapped_column(String(150), nullable=False)
|