48 lines
2.0 KiB
Python
48 lines
2.0 KiB
Python
from datetime import datetime
|
|
|
|
from sqlalchemy import BigInteger, Boolean, DateTime, String, Text, UniqueConstraint, func
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.database import Base
|
|
|
|
|
|
class ApplicationSetting(Base):
|
|
__tablename__ = "application_settings"
|
|
|
|
key: Mapped[str] = mapped_column(String(100), primary_key=True)
|
|
value: Mapped[str] = mapped_column(Text)
|
|
|
|
|
|
class IsoMovie(Base):
|
|
__tablename__ = "iso_movies"
|
|
__table_args__ = (UniqueConstraint("radarr_movie_id", "radarr_movie_file_id"),)
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True)
|
|
radarr_movie_id: Mapped[int] = mapped_column(index=True)
|
|
radarr_movie_file_id: Mapped[int]
|
|
title: Mapped[str] = mapped_column(String(500))
|
|
year: Mapped[int | None]
|
|
path: Mapped[str] = mapped_column(Text)
|
|
size: Mapped[int | None] = mapped_column(BigInteger)
|
|
status: Mapped[str] = mapped_column(String(30), default="detected")
|
|
# Le fichier ISO existe toujours tel quel cote Radarr (mis a jour au scan).
|
|
radarr_linked: Mapped[bool] = mapped_column(Boolean, default=True)
|
|
poster_url: Mapped[str | None] = mapped_column(Text)
|
|
last_seen_at: Mapped[datetime] = mapped_column(
|
|
DateTime(timezone=True), server_default=func.now()
|
|
)
|
|
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
|
processed_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
|
|
completed_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
|
|
failed_step: Mapped[str | None] = mapped_column(String(30))
|
|
last_error: Mapped[str | None] = mapped_column(Text)
|
|
|
|
|
|
class User(Base):
|
|
__tablename__ = "users"
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True)
|
|
username: Mapped[str] = mapped_column(String(100), unique=True)
|
|
password_hash: Mapped[str] = mapped_column(String(255))
|
|
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|