26 lines
1.2 KiB
Python
26 lines
1.2 KiB
Python
"""脚本模板(Python/Node/Shell)。版本由 `version` 字段自增。"""
|
|
from __future__ import annotations
|
|
|
|
from sqlalchemy import ForeignKey, Integer, String, Text
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.db.base import Base, TimestampMixin
|
|
|
|
|
|
class ScriptTemplate(Base, TimestampMixin):
|
|
__tablename__ = "script_template"
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
|
code: Mapped[str] = mapped_column(String(64), nullable=False, unique=True)
|
|
name: Mapped[str] = mapped_column(String(128), nullable=False)
|
|
# python / node / shell
|
|
language: Mapped[str] = mapped_column(String(16), nullable=False, default="python")
|
|
description: Mapped[str | None] = mapped_column(String(255), nullable=True)
|
|
content: Mapped[str] = mapped_column(Text, nullable=False, default="")
|
|
version: Mapped[int] = mapped_column(Integer, nullable=False, default=1)
|
|
timeout_seconds: Mapped[int] = mapped_column(Integer, default=60, nullable=False)
|
|
status: Mapped[str] = mapped_column(String(16), default="ACTIVE", nullable=False)
|
|
owner_id: Mapped[int | None] = mapped_column(
|
|
ForeignKey("user.id", ondelete="SET NULL"), nullable=True
|
|
)
|