add car reservation feature

This commit is contained in:
root
2026-05-09 21:10:38 -04:00
parent 09b0e3b55f
commit 6322b7d2a1
37 changed files with 1169 additions and 119 deletions
@@ -0,0 +1,25 @@
-- CreateEnum
CREATE TYPE "CalendarBlockType" AS ENUM ('MANUAL', 'MAINTENANCE');
-- CreateTable
CREATE TABLE "vehicle_calendar_blocks" (
"id" TEXT NOT NULL,
"vehicleId" TEXT NOT NULL,
"startDate" DATE NOT NULL,
"endDate" DATE NOT NULL,
"reason" TEXT,
"type" "CalendarBlockType" NOT NULL DEFAULT 'MANUAL',
"createdAt" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMPTZ NOT NULL,
CONSTRAINT "vehicle_calendar_blocks_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE INDEX "vehicle_calendar_blocks_vehicleId_idx" ON "vehicle_calendar_blocks"("vehicleId");
-- CreateIndex
CREATE INDEX "vehicle_calendar_blocks_vehicleId_startDate_endDate_idx" ON "vehicle_calendar_blocks"("vehicleId", "startDate", "endDate");
-- AddForeignKey
ALTER TABLE "vehicle_calendar_blocks" ADD CONSTRAINT "vehicle_calendar_blocks_vehicleId_fkey" FOREIGN KEY ("vehicleId") REFERENCES "vehicles"("id") ON DELETE CASCADE ON UPDATE CASCADE;
+26 -3
View File
@@ -315,6 +315,11 @@ enum NotificationStatus {
READ
}
enum CalendarBlockType {
MANUAL
MAINTENANCE
}
// ═══════════════════════════════════════════════════════════════
// B2B — COMPANY SIDE
// ═══════════════════════════════════════════════════════════════
@@ -481,9 +486,10 @@ model Vehicle {
notes String?
isPublished Boolean @default(true)
reservations Reservation[]
maintenance MaintenanceLog[]
offerVehicles OfferVehicle[]
reservations Reservation[]
maintenance MaintenanceLog[]
offerVehicles OfferVehicle[]
calendarBlocks VehicleCalendarBlock[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@ -796,6 +802,23 @@ model MaintenanceLog {
@@map("maintenance_logs")
}
model VehicleCalendarBlock {
id String @id @default(cuid())
vehicleId String
vehicle Vehicle @relation(fields: [vehicleId], references: [id], onDelete: Cascade)
startDate DateTime @db.Date
endDate DateTime @db.Date
reason String?
type CalendarBlockType @default(MANUAL)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([vehicleId])
@@index([vehicleId, startDate, endDate])
@@map("vehicle_calendar_blocks")
}
// ═══════════════════════════════════════════════════════════════
// DOCUMENTS — CONTRACT SETTINGS
// ═══════════════════════════════════════════════════════════════