refactor(models): unify table names to singular form for consistency across models
This commit is contained in:
@@ -9,7 +9,7 @@ from app.database import db
|
|||||||
class Plan(db.Model):
|
class Plan(db.Model):
|
||||||
"""Plan model for user subscription plans."""
|
"""Plan model for user subscription plans."""
|
||||||
|
|
||||||
__tablename__ = "plans"
|
__tablename__ = "plan"
|
||||||
|
|
||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
code = Column(String(50), unique=True, nullable=False, index=True)
|
code = Column(String(50), unique=True, nullable=False, index=True)
|
||||||
|
|||||||
@@ -17,14 +17,14 @@ if TYPE_CHECKING:
|
|||||||
class Playlist(db.Model):
|
class Playlist(db.Model):
|
||||||
"""Model for playlists containing sounds."""
|
"""Model for playlists containing sounds."""
|
||||||
|
|
||||||
__tablename__ = "playlists"
|
__tablename__ = "playlist"
|
||||||
|
|
||||||
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
||||||
name: Mapped[str] = mapped_column(String(255), nullable=False)
|
name: Mapped[str] = mapped_column(String(255), nullable=False)
|
||||||
description: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
|
description: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
|
||||||
genre: Mapped[Optional[str]] = mapped_column(String(100), nullable=True)
|
genre: Mapped[Optional[str]] = mapped_column(String(100), nullable=True)
|
||||||
user_id: Mapped[Optional[int]] = mapped_column(
|
user_id: Mapped[Optional[int]] = mapped_column(
|
||||||
Integer, ForeignKey("users.id"), nullable=True
|
Integer, ForeignKey("user.id"), nullable=True
|
||||||
)
|
)
|
||||||
is_main: Mapped[bool] = mapped_column(
|
is_main: Mapped[bool] = mapped_column(
|
||||||
Boolean, default=False, nullable=False
|
Boolean, default=False, nullable=False
|
||||||
|
|||||||
@@ -17,14 +17,14 @@ if TYPE_CHECKING:
|
|||||||
class PlaylistSound(db.Model):
|
class PlaylistSound(db.Model):
|
||||||
"""Model for playlist-sound relationships with ordering."""
|
"""Model for playlist-sound relationships with ordering."""
|
||||||
|
|
||||||
__tablename__ = "playlist_sounds"
|
__tablename__ = "playlist_sound"
|
||||||
|
|
||||||
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
||||||
playlist_id: Mapped[int] = mapped_column(
|
playlist_id: Mapped[int] = mapped_column(
|
||||||
Integer, ForeignKey("playlists.id"), nullable=False
|
Integer, ForeignKey("playlist.id"), nullable=False
|
||||||
)
|
)
|
||||||
sound_id: Mapped[int] = mapped_column(
|
sound_id: Mapped[int] = mapped_column(
|
||||||
Integer, ForeignKey("sounds.id"), nullable=False
|
Integer, ForeignKey("sound.id"), nullable=False
|
||||||
)
|
)
|
||||||
order: Mapped[int] = mapped_column(Integer, nullable=False)
|
order: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||||
added_at: Mapped[datetime] = mapped_column(
|
added_at: Mapped[datetime] = mapped_column(
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class SoundType(Enum):
|
|||||||
class Sound(db.Model):
|
class Sound(db.Model):
|
||||||
"""Sound model for storing sound file information."""
|
"""Sound model for storing sound file information."""
|
||||||
|
|
||||||
__tablename__ = "sounds"
|
__tablename__ = "sound"
|
||||||
|
|
||||||
id: Mapped[int] = mapped_column(primary_key=True)
|
id: Mapped[int] = mapped_column(primary_key=True)
|
||||||
|
|
||||||
|
|||||||
@@ -19,12 +19,12 @@ class SoundPlayed(db.Model):
|
|||||||
# Foreign keys
|
# Foreign keys
|
||||||
user_id: Mapped[int] = mapped_column(
|
user_id: Mapped[int] = mapped_column(
|
||||||
Integer,
|
Integer,
|
||||||
ForeignKey("users.id"),
|
ForeignKey("user.id"),
|
||||||
nullable=False,
|
nullable=False,
|
||||||
)
|
)
|
||||||
sound_id: Mapped[int] = mapped_column(
|
sound_id: Mapped[int] = mapped_column(
|
||||||
Integer,
|
Integer,
|
||||||
ForeignKey("sounds.id"),
|
ForeignKey("sound.id"),
|
||||||
nullable=False,
|
nullable=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ if TYPE_CHECKING:
|
|||||||
class User(db.Model):
|
class User(db.Model):
|
||||||
"""User model for storing user information."""
|
"""User model for storing user information."""
|
||||||
|
|
||||||
__tablename__ = "users"
|
__tablename__ = "user"
|
||||||
|
|
||||||
id: Mapped[int] = mapped_column(primary_key=True)
|
id: Mapped[int] = mapped_column(primary_key=True)
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ class User(db.Model):
|
|||||||
# Plan relationship
|
# Plan relationship
|
||||||
plan_id: Mapped[int] = mapped_column(
|
plan_id: Mapped[int] = mapped_column(
|
||||||
Integer,
|
Integer,
|
||||||
ForeignKey("plans.id"),
|
ForeignKey("plan.id"),
|
||||||
nullable=False,
|
nullable=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class UserOAuth(db.Model):
|
|||||||
id: Mapped[int] = mapped_column(primary_key=True)
|
id: Mapped[int] = mapped_column(primary_key=True)
|
||||||
|
|
||||||
# User relationship
|
# User relationship
|
||||||
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), nullable=False)
|
user_id: Mapped[int] = mapped_column(ForeignKey("user.id"), nullable=False)
|
||||||
|
|
||||||
# OAuth provider information
|
# OAuth provider information
|
||||||
provider: Mapped[str] = mapped_column(String(50), nullable=False)
|
provider: Mapped[str] = mapped_column(String(50), nullable=False)
|
||||||
|
|||||||
Reference in New Issue
Block a user