19 lines
819 B
Python
19 lines
819 B
Python
from sqlalchemy import Column, Integer, ForeignKey, DateTime, String
|
|
from sqlalchemy.orm import relationship
|
|
from app.core.database import Base
|
|
from datetime import datetime
|
|
|
|
class Booking(Base):
|
|
__tablename__ = "bookings"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
user_id = Column(Integer, ForeignKey("users.id"), nullable=False)
|
|
product_id = Column(Integer, ForeignKey("products.id"), nullable=False)
|
|
amount = Column(Integer, nullable=False) # Anzahl der Produkte in dieser Buchung
|
|
total_cents = Column(Integer, nullable=False) # Gesamtsumme in Cent (Preis * Anzahl)
|
|
comment = Column(String, nullable=True)
|
|
timestamp = Column(DateTime, default=datetime.utcnow, nullable=False) # Zeitpunkt der Buchung
|
|
|
|
user = relationship("User")
|
|
product = relationship("Product")
|