- Migrated all schemas to Pydantic v2 syntax (model_config, ConfigDict) - Fixed mutable default in ProtoMessageBase using Field(default_factory=datetime.now) - Consolidated CardCollection and Wishlist schemas in user_card_collection.py - Created game_schemas.py with GameCreate, GameResponse, GameJoinRequest, etc. - Created mtg_card_schemas.py with MtgCardResponse, MtgCardSearchRequest, etc. - Added CardImportBatchCreate, CardImportBatchResponse, UserCardImportCreate/Response schemas - Fixed duplicate UserCardImportRecord class between card_import_batch.py and user_card_import_record.py - Updated __init__.py with comprehensive schema exports - Created verify_schemas.py for schema-model matching verification
41 lines
1.4 KiB
Python
41 lines
1.4 KiB
Python
"""
|
|
SQLAlchemy ORM model for user card imports.
|
|
|
|
This model corresponds to the user_card_imports table created in migration 004.
|
|
It stores a user's imported card collection as a JSON array of card names.
|
|
"""
|
|
from sqlalchemy import (
|
|
Column, Integer, String, BigInteger, DateTime, Text,
|
|
ForeignKey, UniqueConstraint
|
|
)
|
|
from sqlalchemy.orm import relationship
|
|
from sqlalchemy.sql import func
|
|
from app.core.database import Base
|
|
|
|
|
|
class UserCardImport(Base):
|
|
"""
|
|
User card import record.
|
|
|
|
Stores a user's imported card collection as a JSON array of card names.
|
|
This table was created in migration 004 and may be superseded by
|
|
CardImportBatch and UserCardImportRecord in migration 005.
|
|
"""
|
|
__tablename__ = "user_card_imports"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
user_id = Column(Integer, ForeignKey("mtgonline_users.id", ondelete="CASCADE"), nullable=False)
|
|
card_names_json = Column(Text, nullable=False) # JSON array of card names
|
|
created_at = Column(DateTime, server_default=func.now())
|
|
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now())
|
|
|
|
# Relationships
|
|
user = relationship("User", backref="card_imports")
|
|
|
|
__table_args__ = (
|
|
UniqueConstraint('user_id', name='uq_user_card_imports_user_id'),
|
|
)
|
|
|
|
def __repr__(self) -> str:
|
|
return f"<UserCardImport user={self.user_id}>"
|