more stuff yay
This commit is contained in:
21
db/models.py
21
db/models.py
@@ -113,7 +113,8 @@ class Box(Base):
|
||||
|
||||
product_id = Column(String, ForeignKey("products.id"), primary_key=True)
|
||||
type = Column(String) # collector box, play box, etc.
|
||||
sku = Column(String)
|
||||
set_code = Column(String)
|
||||
sku = Column(String, nullable=True)
|
||||
num_cards_expected = Column(Integer, nullable=True)
|
||||
date_created = Column(DateTime, default=datetime.now)
|
||||
date_modified = Column(DateTime, default=datetime.now, onupdate=datetime.now)
|
||||
@@ -208,7 +209,7 @@ class Warehouse(Base):
|
||||
__tablename__ = "warehouse"
|
||||
|
||||
id = Column(String, primary_key=True)
|
||||
user_id = Column(String, ForeignKey("users.id"), default="admin")
|
||||
user_id = Column(String, ForeignKey("users.id"))
|
||||
date_created = Column(DateTime, default=datetime.now)
|
||||
date_modified = Column(DateTime, default=datetime.now, onupdate=datetime.now)
|
||||
|
||||
@@ -246,6 +247,7 @@ class User(Base):
|
||||
__tablename__ = "users"
|
||||
|
||||
id = Column(String, primary_key=True)
|
||||
username = Column(String)
|
||||
date_created = Column(DateTime, default=datetime.now)
|
||||
date_modified = Column(DateTime, default=datetime.now, onupdate=datetime.now)
|
||||
|
||||
@@ -283,6 +285,7 @@ class File(Base):
|
||||
filepath = Column(String) # backup location
|
||||
filesize_kb = Column(Float)
|
||||
status = Column(String)
|
||||
box_id = Column(String, ForeignKey("boxes.product_id"), nullable=True)
|
||||
date_created = Column(DateTime, default=datetime.now)
|
||||
date_modified = Column(DateTime, default=datetime.now, onupdate=datetime.now)
|
||||
|
||||
@@ -303,9 +306,16 @@ class StorageBlock(Base):
|
||||
"""
|
||||
__tablename__ = "storage_blocks"
|
||||
|
||||
@validates("type")
|
||||
def validate_type(self, key, type: str):
|
||||
if type not in StorageBlockTypeEnum or type.lower() not in StorageBlockTypeEnum:
|
||||
raise ValueError(f"Invalid storage block type: {type}")
|
||||
return type
|
||||
|
||||
id = Column(String, primary_key=True)
|
||||
warehouse_id = Column(String, ForeignKey("warehouse.id"))
|
||||
name = Column(String)
|
||||
type = Column(String) # rare or common
|
||||
date_created = Column(DateTime, default=datetime.now)
|
||||
date_modified = Column(DateTime, default=datetime.now, onupdate=datetime.now)
|
||||
|
||||
@@ -530,6 +540,7 @@ class BoxTypeEnum(str, Enum):
|
||||
PLAY = "play"
|
||||
DRAFT = "draft"
|
||||
COMMANDER = "commander"
|
||||
SET = "set"
|
||||
|
||||
class ProductLineEnum(str, Enum):
|
||||
MTG = "mtg"
|
||||
@@ -537,4 +548,8 @@ class ProductLineEnum(str, Enum):
|
||||
|
||||
class ProductTypeEnum(str, Enum):
|
||||
BOX = "box"
|
||||
CARD = "card"
|
||||
CARD = "card"
|
||||
|
||||
class StorageBlockTypeEnum(str, Enum):
|
||||
RARE = "rare"
|
||||
COMMON = "common"
|
Reference in New Issue
Block a user