Backend: SQLAlchemy models, Alembic migrations, requirements lockfile. Frontend: pinned deps, package-lock, vite-env types fix. Verified compose build/health, pytest, ruff clean.
30 lines
1.3 KiB
Python
30 lines
1.3 KiB
Python
import uuid
|
|
from datetime import datetime
|
|
|
|
from sqlalchemy import Boolean, DateTime, ForeignKey, Integer, String
|
|
from sqlalchemy.dialects.postgresql import UUID
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.core.db import Base
|
|
from app.models.mixins import TimestampMixin, UUIDPrimaryKeyMixin
|
|
|
|
BOOKING_STATUSES = ("reserved", "active", "returned", "cancelled", "blocked")
|
|
|
|
|
|
class Booking(UUIDPrimaryKeyMixin, TimestampMixin, Base):
|
|
__tablename__ = "bookings"
|
|
|
|
public_ref: Mapped[str] = mapped_column(String(20), unique=True, nullable=False)
|
|
customer_id: Mapped[uuid.UUID] = mapped_column(
|
|
UUID(as_uuid=True), ForeignKey("customers.id"), nullable=False
|
|
)
|
|
vehicle_id: Mapped[uuid.UUID] = mapped_column(
|
|
UUID(as_uuid=True), ForeignKey("vehicles.id"), nullable=False
|
|
)
|
|
starts_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False)
|
|
ends_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False)
|
|
status: Mapped[str] = mapped_column(String(20), nullable=False)
|
|
start_odometer_km: Mapped[int | None] = mapped_column(Integer)
|
|
end_odometer_km: Mapped[int | None] = mapped_column(Integer)
|
|
requirements_complete: Mapped[bool] = mapped_column(Boolean, nullable=False, default=True)
|