
- FastAPI application with user management, destinations, and trip planning - SQLite database with SQLAlchemy ORM - Database models for Users, Destinations, and Trips - Pydantic schemas for request/response validation - Full CRUD API endpoints for all resources - Alembic migrations setup - Health check endpoint - CORS configuration for development - Comprehensive documentation and README
24 lines
1002 B
Python
24 lines
1002 B
Python
from sqlalchemy import Column, Integer, String, Text, DateTime, ForeignKey, Float
|
|
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)
|
|
user_id = Column(Integer, ForeignKey("users.id"), nullable=False)
|
|
destination_id = Column(Integer, ForeignKey("destinations.id"), nullable=False)
|
|
start_date = Column(DateTime, nullable=False)
|
|
end_date = Column(DateTime, nullable=False)
|
|
budget = Column(Float)
|
|
status = Column(String, default="planned") # planned, ongoing, completed, cancelled
|
|
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")
|
|
destination = relationship("Destination", back_populates="trips")
|