from sqlalchemy import Column, Integer, String, DateTime, ForeignKey
from sqlalchemy.orm import relationship
from sqlalchemy.sql import func
from app.db.database import Base

class Box(Base):
    __tablename__ = "boxes"

    id = Column(Integer, primary_key=True, index=True)
    product_id = Column(Integer)
    type = Column(String)
    set_code = Column(String)
    sku = Column(Integer)
    name = Column(String)
    game_id = Column(Integer, ForeignKey("games.id"))
    expected_number_of_cards = Column(Integer)
    description = Column(String)
    image_url = Column(String)
    created_at = Column(DateTime(timezone=True), server_default=func.now())
    updated_at = Column(DateTime(timezone=True), onupdate=func.now())

class OpenBox(Base):
    __tablename__ = "open_boxes"

    id = Column(Integer, primary_key=True, index=True)
    box_id = Column(Integer, ForeignKey("boxes.id"))
    number_of_cards = Column(Integer)
    date_opened = Column(DateTime(timezone=True))
    created_at = Column(DateTime(timezone=True), server_default=func.now())
    updated_at = Column(DateTime(timezone=True), onupdate=func.now())
