fix(migrations): don't create foreign key constraints in playlist_best_scores migration

This commit is contained in:
MingxuanGame
2025-11-30 00:44:42 +08:00
parent 31ccc9f0a2
commit ab8c809ea0
2 changed files with 12 additions and 14 deletions

View File

@@ -792,10 +792,10 @@ def upgrade() -> None:
sa.Column("playlist_id", sa.Integer(), nullable=False), sa.Column("playlist_id", sa.Integer(), nullable=False),
sa.Column("total_score", sa.BigInteger(), nullable=True), sa.Column("total_score", sa.BigInteger(), nullable=True),
sa.Column("attempts", sa.Integer(), nullable=False), sa.Column("attempts", sa.Integer(), nullable=False),
sa.ForeignKeyConstraint( # sa.ForeignKeyConstraint(
["playlist_id"], # ["playlist_id"],
["room_playlists.id"], # ["room_playlists.id"],
), # ),
sa.ForeignKeyConstraint( sa.ForeignKeyConstraint(
["room_id"], ["room_id"],
["rooms.id"], ["rooms.id"],

View File

@@ -8,8 +8,6 @@ Create Date: 2025-08-13 15:17:53.921545
from collections.abc import Sequence from collections.abc import Sequence
from alembic import op
# revision identifiers, used by Alembic. # revision identifiers, used by Alembic.
revision: str = "9aa4f7c06824" revision: str = "9aa4f7c06824"
down_revision: str | Sequence[str] | None = "8bab62d764a5" down_revision: str | Sequence[str] | None = "8bab62d764a5"
@@ -20,18 +18,18 @@ depends_on: str | Sequence[str] | None = None
def upgrade() -> None: def upgrade() -> None:
"""Upgrade schema.""" """Upgrade schema."""
# ### commands auto generated by Alembic - please adjust! ### # ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(op.f("playlist_best_scores_ibfk_1"), "playlist_best_scores", type_="foreignkey") # op.drop_constraint(op.f("playlist_best_scores_ibfk_1"), "playlist_best_scores", type_="foreignkey")
# ### end Alembic commands ### # ### end Alembic commands ###
def downgrade() -> None: def downgrade() -> None:
"""Downgrade schema.""" """Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ### # ### commands auto generated by Alembic - please adjust! ###
op.create_foreign_key( # op.create_foreign_key(
op.f("playlist_best_scores_ibfk_1"), # op.f("playlist_best_scores_ibfk_1"),
"playlist_best_scores", # "playlist_best_scores",
"room_playlists", # "room_playlists",
["playlist_id"], # ["playlist_id"],
["id"], # ["id"],
) # )
# ### end Alembic commands ### # ### end Alembic commands ###