feat: Add Extraction model and seed main playlist functionality
This commit is contained in:
@@ -9,7 +9,7 @@ if TYPE_CHECKING:
|
||||
from app.models.user import User
|
||||
|
||||
|
||||
class Stream(BaseModel, table=True):
|
||||
class Extraction(BaseModel, table=True):
|
||||
"""Database model for a stream."""
|
||||
|
||||
service: str = Field(nullable=False)
|
||||
@@ -30,10 +30,10 @@ class Stream(BaseModel, table=True):
|
||||
UniqueConstraint(
|
||||
"service",
|
||||
"service_id",
|
||||
name="uq_stream_service_service_id",
|
||||
name="uq_extraction_service_service_id",
|
||||
),
|
||||
)
|
||||
|
||||
# relationships
|
||||
sound: "Sound" = Relationship(back_populates="streams")
|
||||
user: "User" = Relationship(back_populates="streams")
|
||||
sound: "Sound" = Relationship(back_populates="extractions")
|
||||
user: "User" = Relationship(back_populates="extractions")
|
||||
@@ -5,9 +5,9 @@ from sqlmodel import Field, Relationship
|
||||
from app.models.base import BaseModel
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from app.models.extraction import Extraction
|
||||
from app.models.playlist_sound import PlaylistSound
|
||||
from app.models.sound_played import SoundPlayed
|
||||
from app.models.stream import Stream
|
||||
|
||||
|
||||
class Sound(BaseModel, table=True):
|
||||
@@ -31,5 +31,5 @@ class Sound(BaseModel, table=True):
|
||||
|
||||
# relationships
|
||||
playlist_sounds: list["PlaylistSound"] = Relationship(back_populates="sound")
|
||||
streams: list["Stream"] = Relationship(back_populates="sound")
|
||||
extractions: list["Extraction"] = Relationship(back_populates="sound")
|
||||
play_history: list["SoundPlayed"] = Relationship(back_populates="sound")
|
||||
|
||||
@@ -6,10 +6,10 @@ from sqlmodel import Field, Relationship
|
||||
from app.models.base import BaseModel
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from app.models.extraction import Extraction
|
||||
from app.models.plan import Plan
|
||||
from app.models.playlist import Playlist
|
||||
from app.models.sound_played import SoundPlayed
|
||||
from app.models.stream import Stream
|
||||
from app.models.user_oauth import UserOauth
|
||||
|
||||
|
||||
@@ -34,4 +34,4 @@ class User(BaseModel, table=True):
|
||||
plan: "Plan" = Relationship(back_populates="users")
|
||||
playlists: list["Playlist"] = Relationship(back_populates="user")
|
||||
sounds_played: list["SoundPlayed"] = Relationship(back_populates="user")
|
||||
streams: list["Stream"] = Relationship(back_populates="user")
|
||||
extractions: list["Extraction"] = Relationship(back_populates="user")
|
||||
|
||||
Reference in New Issue
Block a user