Some checks failed
Tests / Backend Tests (Python) (3.10) (push) Has been cancelled
Tests / Backend Tests (Python) (3.11) (push) Has been cancelled
Tests / Backend Tests (Python) (3.12) (push) Has been cancelled
Tests / Frontend Tests (JS) (push) Has been cancelled
Tests / Integration Tests (push) Has been cancelled
Tests / All Tests Passed (push) Has been cancelled
33 lines
1.4 KiB
Python
33 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from sqlalchemy import DateTime, ForeignKey, Integer, String, UniqueConstraint
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
from sqlalchemy.sql import func
|
|
|
|
from .database import Base
|
|
|
|
|
|
class ContainerCustomization(Base):
|
|
__tablename__ = "container_customizations"
|
|
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
|
user_id: Mapped[Optional[int]] = mapped_column(Integer, ForeignKey("users.id", ondelete="CASCADE"), nullable=True)
|
|
|
|
host_id: Mapped[str] = mapped_column(String, ForeignKey("hosts.id", ondelete="CASCADE"), nullable=False)
|
|
container_id: Mapped[str] = mapped_column(String(64), nullable=False)
|
|
|
|
icon_key: Mapped[Optional[str]] = mapped_column(String(100), nullable=True)
|
|
icon_color: Mapped[Optional[str]] = mapped_column(String(20), nullable=True)
|
|
bg_color: Mapped[Optional[str]] = mapped_column(String(20), nullable=True)
|
|
|
|
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False, server_default=func.now())
|
|
updated_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False, server_default=func.now(), onupdate=func.now())
|
|
|
|
__table_args__ = (
|
|
UniqueConstraint("user_id", "host_id", "container_id", name="uq_container_customizations_user_host_container"),
|
|
{"sqlite_autoincrement": True},
|
|
)
|