update to python fastpi
This commit is contained in:
40
Backend/src/models/booking.py
Normal file
40
Backend/src/models/booking.py
Normal file
@@ -0,0 +1,40 @@
|
||||
from sqlalchemy import Column, Integer, String, DateTime, Numeric, Boolean, Text, Enum, ForeignKey
|
||||
from sqlalchemy.orm import relationship
|
||||
from datetime import datetime
|
||||
import enum
|
||||
from ..config.database import Base
|
||||
|
||||
|
||||
class BookingStatus(str, enum.Enum):
|
||||
pending = "pending"
|
||||
confirmed = "confirmed"
|
||||
checked_in = "checked_in"
|
||||
checked_out = "checked_out"
|
||||
cancelled = "cancelled"
|
||||
|
||||
|
||||
class Booking(Base):
|
||||
__tablename__ = "bookings"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True, autoincrement=True)
|
||||
booking_number = Column(String(50), unique=True, nullable=False, index=True)
|
||||
user_id = Column(Integer, ForeignKey("users.id"), nullable=False)
|
||||
room_id = Column(Integer, ForeignKey("rooms.id"), nullable=False)
|
||||
check_in_date = Column(DateTime, nullable=False)
|
||||
check_out_date = Column(DateTime, nullable=False)
|
||||
num_guests = Column(Integer, nullable=False, default=1)
|
||||
total_price = Column(Numeric(10, 2), nullable=False)
|
||||
status = Column(Enum(BookingStatus), nullable=False, default=BookingStatus.pending)
|
||||
deposit_paid = Column(Boolean, nullable=False, default=False)
|
||||
requires_deposit = Column(Boolean, nullable=False, default=False)
|
||||
special_requests = Column(Text, nullable=True)
|
||||
created_at = Column(DateTime, default=datetime.utcnow, nullable=False)
|
||||
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False)
|
||||
|
||||
# Relationships
|
||||
user = relationship("User", back_populates="bookings")
|
||||
room = relationship("Room", back_populates="bookings")
|
||||
payments = relationship("Payment", back_populates="booking", cascade="all, delete-orphan")
|
||||
service_usages = relationship("ServiceUsage", back_populates="booking", cascade="all, delete-orphan")
|
||||
checkin_checkout = relationship("CheckInCheckOut", back_populates="booking", uselist=False)
|
||||
|
||||
Reference in New Issue
Block a user