32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
import uuid
|
|
from typing import TYPE_CHECKING
|
|
|
|
from sqlalchemy import ForeignKey, Integer, JSON, 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
|
|
|
|
|
|
class ConfigMount(UUIDPrimaryKeyMixin, TimestampMixin, Base):
|
|
__tablename__ = "config_mounts"
|
|
|
|
profile_id: Mapped[uuid.UUID] = mapped_column(
|
|
UUID(), ForeignKey("config_profiles.id", ondelete="CASCADE"), nullable=False
|
|
)
|
|
target_path: Mapped[str] = mapped_column(String(1024), nullable=False)
|
|
mode: Mapped[str] = mapped_column(String(10), nullable=False, default="rw")
|
|
files: Mapped[dict[str, str] | None] = mapped_column(
|
|
JSON, default=dict, nullable=True
|
|
)
|
|
order_index: Mapped[int] = mapped_column(Integer, nullable=False, default=0)
|
|
|
|
profile: Mapped["ConfigProfile"] = relationship(
|
|
"ConfigProfile",
|
|
foreign_keys=[profile_id],
|
|
back_populates="mounts",
|
|
)
|