mirror of
https://github.com/rommapp/romm.git
synced 2026-11-30 18:42:34 +01:00
Prevents errors when migrations are re-run against a database that already has (or has already dropped) the target indexes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
45 lines
1.3 KiB
Python
45 lines
1.3 KiB
Python
"""Add HowLongToBeat metadata fields
|
|
|
|
Revision ID: 0053_add_hltb_metadata
|
|
Revises: 0052_roms_metadata_flashpoint
|
|
Create Date: 2025-09-14 00:00:00.000000
|
|
|
|
"""
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
from sqlalchemy.dialects import postgresql
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = "0053_add_hltb_metadata"
|
|
down_revision = "0052_roms_metadata_flashpoint"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
with op.batch_alter_table("roms", schema=None) as batch_op:
|
|
batch_op.add_column(
|
|
sa.Column("hltb_id", sa.Integer(), nullable=True), if_not_exists=True
|
|
)
|
|
batch_op.add_column(
|
|
sa.Column(
|
|
"hltb_metadata",
|
|
sa.JSON().with_variant(
|
|
postgresql.JSONB(astext_type=sa.Text()), "postgresql"
|
|
),
|
|
nullable=True,
|
|
),
|
|
if_not_exists=True,
|
|
)
|
|
batch_op.create_index(
|
|
"idx_roms_hltb_id", ["hltb_id"], unique=False, if_not_exists=True
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
with op.batch_alter_table("roms", schema=None) as batch_op:
|
|
batch_op.drop_index("idx_roms_hltb_id", if_exists=True)
|
|
batch_op.drop_column("hltb_metadata", if_exists=True)
|
|
batch_op.drop_column("hltb_id", if_exists=True)
|