playlist_best_scores: remove foreign key to allow to remove items

This commit is contained in:
MingxuanGame
2025-08-13 15:18:26 +00:00
parent 2e44951533
commit 858a7e8640
2 changed files with 42 additions and 1 deletions

View File

@@ -30,7 +30,7 @@ class PlaylistBestScore(SQLModel, table=True):
sa_column=Column(BigInteger, ForeignKey("scores.id"), primary_key=True)
)
room_id: int = Field(foreign_key="rooms.id", index=True)
playlist_id: int = Field(foreign_key="room_playlists.id", index=True)
playlist_id: int = Field(index=True)
total_score: int = Field(default=0, sa_column=Column(BigInteger))
attempts: int = Field(default=0) # playlist

View File

@@ -0,0 +1,41 @@
"""playlist_best_scores: remove foreign key to allow to remove items
Revision ID: 9aa4f7c06824
Revises: 8bab62d764a5
Create Date: 2025-08-13 15:17:53.921545
"""
from __future__ import annotations
from collections.abc import Sequence
from alembic import op
# revision identifiers, used by Alembic.
revision: str = "9aa4f7c06824"
down_revision: str | Sequence[str] | None = "8bab62d764a5"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None
def upgrade() -> None:
"""Upgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(
op.f("playlist_best_scores_ibfk_1"), "playlist_best_scores", type_="foreignkey"
)
# ### end Alembic commands ###
def downgrade() -> None:
"""Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.create_foreign_key(
op.f("playlist_best_scores_ibfk_1"),
"playlist_best_scores",
"room_playlists",
["playlist_id"],
["id"],
)
# ### end Alembic commands ###