
- User authentication with JWT tokens - Trip management with itineraries - Destination database with search functionality - Booking management for flights, hotels, car rentals, activities - SQLite database with Alembic migrations - Health monitoring endpoint - CORS enabled for all origins - Complete API documentation at /docs and /redoc - Environment variable support for SECRET_KEY Requirements for production: - Set SECRET_KEY environment variable
41 lines
1.6 KiB
Python
41 lines
1.6 KiB
Python
from sqlalchemy import Column, Integer, String, DateTime, Text, ForeignKey, Numeric
|
|
from sqlalchemy.orm import relationship
|
|
from sqlalchemy.sql import func
|
|
from app.db.base import Base
|
|
|
|
|
|
class Trip(Base):
|
|
__tablename__ = "trips"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
title = Column(String, nullable=False)
|
|
description = Column(Text)
|
|
start_date = Column(DateTime, nullable=False)
|
|
end_date = Column(DateTime, nullable=False)
|
|
budget = Column(Numeric(10, 2))
|
|
status = Column(String, default="planned") # planned, active, completed, cancelled
|
|
user_id = Column(Integer, ForeignKey("users.id"), nullable=False)
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
|
|
|
user = relationship("User", back_populates="trips")
|
|
itinerary = relationship("Itinerary", back_populates="trip")
|
|
bookings = relationship("Booking", back_populates="trip")
|
|
|
|
|
|
class Itinerary(Base):
|
|
__tablename__ = "itineraries"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
trip_id = Column(Integer, ForeignKey("trips.id"), nullable=False)
|
|
destination_id = Column(Integer, ForeignKey("destinations.id"), nullable=False)
|
|
day_number = Column(Integer, nullable=False)
|
|
activity = Column(String, nullable=False)
|
|
description = Column(Text)
|
|
start_time = Column(DateTime)
|
|
end_time = Column(DateTime)
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
|
|
trip = relationship("Trip", back_populates="itinerary")
|
|
destination = relationship("Destination")
|