Phase 2 Complete: SQL migration with SQLModel and Alembic
This commit is contained in:
+22
-1
@@ -74,7 +74,7 @@ class WatchlistItemTable(WatchlistItemBase, table=True):
|
||||
def genres(self, value: List[str]):
|
||||
self.genres_json = json.dumps(value or [])
|
||||
|
||||
# Relationships
|
||||
# Relationships - Using string reference
|
||||
user: Optional["UserTable"] = Relationship(back_populates="watchlist_items")
|
||||
|
||||
|
||||
@@ -148,6 +148,24 @@ class AutoDownloadResult(BaseModel):
|
||||
checked_at: datetime = PydanticField(default_factory=datetime.now)
|
||||
|
||||
|
||||
class WatchlistSettingsBase(SQLModel):
|
||||
check_interval_hours: int = Field(default=6)
|
||||
auto_download_enabled: bool = Field(default=True)
|
||||
max_concurrent_auto_downloads: int = Field(default=2)
|
||||
notify_on_new_episodes: bool = Field(default=False)
|
||||
include_completed_anime: bool = Field(default=False)
|
||||
|
||||
class WatchlistSettingsTable(WatchlistSettingsBase, table=True):
|
||||
"""Database table for global watchlist settings"""
|
||||
__tablename__ = "watchlist_settings"
|
||||
id: str = Field(
|
||||
default_factory=lambda: str(uuid.uuid4()),
|
||||
primary_key=True,
|
||||
index=True,
|
||||
nullable=False
|
||||
)
|
||||
user_id: str = Field(foreign_key="users.id", index=True, default="default")
|
||||
|
||||
class WatchlistSettings(BaseModel):
|
||||
"""Global watchlist settings"""
|
||||
check_interval_hours: int = PydanticField(default=6, ge=1, le=168)
|
||||
@@ -155,3 +173,6 @@ class WatchlistSettings(BaseModel):
|
||||
max_concurrent_auto_downloads: int = PydanticField(default=2, ge=1, le=10)
|
||||
notify_on_new_episodes: bool = PydanticField(default=False)
|
||||
include_completed_anime: bool = PydanticField(default=False)
|
||||
|
||||
# Import UserTable here to resolve SQLModel Relationship mappings
|
||||
from .auth import UserTable
|
||||
|
||||
Reference in New Issue
Block a user