22 lines
719 B
Python
22 lines
719 B
Python
from sqlalchemy import ForeignKey
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
from ttfrog.db.schema.inventory import Inventory, InventoryType
|
|
from ttfrog.db.schema.item import Item, ItemType
|
|
|
|
__all__ = [
|
|
"Container",
|
|
]
|
|
|
|
|
|
class Container(Item):
|
|
__tablename__ = "container"
|
|
__mapper_args__ = {"polymorphic_identity": ItemType.CONTAINER}
|
|
id: Mapped[int] = mapped_column(ForeignKey("item.id"), primary_key=True, init=False)
|
|
item_type: Mapped[ItemType] = ItemType.CONTAINER
|
|
inventory: Mapped["Inventory"] = relationship(
|
|
cascade="all,delete,delete-orphan",
|
|
lazy="immediate",
|
|
default_factory=lambda: Inventory(inventory_type=InventoryType.EQUIPMENT),
|
|
)
|