22c035984e
- Add ConfigProfile model with user ownership, name, description - Add ConfigInclude model for ordered profile self-references - Add ConfigMount model for mount/file definitions - Add selected_profile_id to ToolInstance for per-instance profile selection - Add default profile properties to UserConfig JSONB config - Create Alembic migration 0013 for new tables and columns - Register new models in models/__init__.py - Mark config_folders.is_active as deprecated - Add migration metadata test Quality gates: syntax check passed (all files parse successfully) OpenSpec: add-config-profiles task 1.1
75 lines
2.6 KiB
Python
75 lines
2.6 KiB
Python
import uuid
|
|
from datetime import datetime
|
|
from typing import TYPE_CHECKING
|
|
|
|
from sqlalchemy import DateTime, ForeignKey, Integer, String
|
|
from sqlalchemy import Uuid as UUID
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
from src.models.base import Base, TimestampMixin, UUIDPrimaryKeyMixin
|
|
|
|
if TYPE_CHECKING:
|
|
from src.models.config_profile import ConfigProfile
|
|
from src.models.git_repository import GitRepository
|
|
from src.models.project import Project
|
|
from src.models.tool_type import ToolType
|
|
from src.models.user import User
|
|
|
|
|
|
class ToolInstance(UUIDPrimaryKeyMixin, TimestampMixin, Base):
|
|
__tablename__ = "tool_instances"
|
|
|
|
name: Mapped[str] = mapped_column(String(255), nullable=False)
|
|
display_name: Mapped[str] = mapped_column(String(255), nullable=False)
|
|
tool_type_id: Mapped[uuid.UUID] = mapped_column(
|
|
UUID(), ForeignKey("tool_types.id"), nullable=False
|
|
)
|
|
repository_id: Mapped[uuid.UUID] = mapped_column(
|
|
UUID(), ForeignKey("git_repositories.id"), nullable=False
|
|
)
|
|
project_id: Mapped[uuid.UUID] = mapped_column(
|
|
UUID(), ForeignKey("projects.id"), nullable=False
|
|
)
|
|
owner_id: Mapped[uuid.UUID] = mapped_column(
|
|
UUID(), ForeignKey("users.id"), nullable=False
|
|
)
|
|
status: Mapped[str] = mapped_column(
|
|
String(50), nullable=False, default="pending"
|
|
)
|
|
container_id: Mapped[str | None] = mapped_column(
|
|
String(255), nullable=True
|
|
)
|
|
container_name: Mapped[str | None] = mapped_column(
|
|
String(255), nullable=True
|
|
)
|
|
compose_path: Mapped[str | None] = mapped_column(
|
|
String(1024), nullable=True
|
|
)
|
|
url: Mapped[str | None] = mapped_column(
|
|
String(1024), nullable=True
|
|
)
|
|
public_url: Mapped[str | None] = mapped_column(
|
|
String(1024), nullable=True
|
|
)
|
|
tunnel_id: Mapped[str | None] = mapped_column(
|
|
String(255), nullable=True
|
|
)
|
|
port: Mapped[int | None] = mapped_column(
|
|
Integer, nullable=True
|
|
)
|
|
last_started_at: Mapped[datetime | None] = mapped_column(
|
|
DateTime(timezone=True), nullable=True
|
|
)
|
|
last_stopped_at: Mapped[datetime | None] = mapped_column(
|
|
DateTime(timezone=True), nullable=True
|
|
)
|
|
selected_profile_id: Mapped[uuid.UUID | None] = mapped_column(
|
|
UUID(), ForeignKey("config_profiles.id", ondelete="SET NULL"), nullable=True
|
|
)
|
|
|
|
tool_type: Mapped["ToolType"] = relationship()
|
|
repository: Mapped["GitRepository"] = relationship()
|
|
project: Mapped["Project"] = relationship()
|
|
owner: Mapped["User"] = relationship()
|
|
selected_profile: Mapped["ConfigProfile | None"] = relationship()
|