Files
mtgonline/backend/app/models/relationships.py
T
akadmin bea91db64d Phase 3: Schema Layer - Pydantic v2 migration, deduplication, and missing schemas
- 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
2026-08-16 05:22:17 +00:00

25 lines
817 B
Python

"""
Cross-model relationships.
This module defines relationships that reference models from other
model files (e.g., DecklistFile.card_links → DeckCardLink). These
must be defined AFTER all model classes have been imported to avoid
circular import issues.
Import this module LAST in app/models/__init__.py.
"""
from sqlalchemy.orm import relationship
from app.models.models import DecklistFile
from app.models.mirror_models import DeckCardLink
# Add the back-reference from DecklistFile to DeckCardLink.
# This was previously defined dynamically at the bottom of mirror_models.py,
# but that caused circular imports. Now it lives here and is imported last.
DecklistFile.card_links = relationship(
"DeckCardLink",
back_populates="deck",
cascade="all, delete-orphan",
order_by="DeckCardLink.id"
)