- Add UserCardImport model (stores imported card names as JSON) - Create card_import_schemas.py with request/response models - Create card_import.py router with import/get/delete endpoints - Add Alembic migration 004 (user_card_imports table) - Fuzzy matching for card name matching (60% threshold) - Integration with deckbuilding via imported cards - Endpoints: GET /api/v1/card-import/status, POST /, DELETE /, GET /summary
37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
"""
|
|
Alembic migration: Create user_card_imports table.
|
|
|
|
This migration adds the user_card_imports table which stores
|
|
a user's imported card collection as a JSON array of card names.
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '004'
|
|
down_revision = '003'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
"""Create user_card_imports table."""
|
|
op.create_table(
|
|
'user_card_imports',
|
|
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
|
sa.Column('user_id', sa.Integer(), nullable=False),
|
|
sa.Column('card_names_json', sa.Text(), nullable=False),
|
|
sa.Column('created_at', sa.DateTime(), server_default=sa.func.now()),
|
|
sa.Column('updated_at', sa.DateTime(), server_default=sa.func.now(), onupdate=sa.func.now()),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.ForeignKeyConstraint(['user_id'], ['mtgonline_users.id'], ondelete='CASCADE'),
|
|
sa.UniqueConstraint('user_id', name='uq_user_card_imports_user_id'),
|
|
sa.Index('idx_user_card_imports_user', 'user_id'),
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
"""Drop user_card_imports table."""
|
|
op.drop_table('user_card_imports')
|