"""fix foreign key issue

Revision ID: fix_foreign_key_issue
Revises: 5bf5f87793d7
Create Date: 2025-04-14 04:15:00.000000

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = 'fix_foreign_key_issue'
down_revision: Union[str, None] = '5bf5f87793d7'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    # Drop the foreign key constraint if it exists
    op.execute('ALTER TABLE mtgjson_skus DROP CONSTRAINT IF EXISTS mtgjson_skus_card_id_fkey')
    # Make the column nullable
    op.alter_column('mtgjson_skus', 'card_id',
               existing_type=sa.String(),
               nullable=True)


def downgrade() -> None:
    # No downgrade - we don't want to recreate the constraint
    pass 