fix: Add missing relations to Prisma schema (Pet/Booking, Invoice/Booking)
This commit is contained in:
@@ -9,6 +9,19 @@ COPY . .
|
||||
RUN npx prisma generate
|
||||
RUN npm run build
|
||||
|
||||
FROM node:22-alpine AS dev
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package.json yarn.lock* ./
|
||||
RUN yarn install --frozen-lockfile 2>/dev/null || npm install
|
||||
|
||||
COPY . .
|
||||
RUN npx prisma generate
|
||||
|
||||
EXPOSE 3000
|
||||
CMD ["npm", "run", "start:dev"]
|
||||
|
||||
FROM node:22-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
+63
-54
@@ -1,3 +1,12 @@
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
model Client {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
@@ -15,6 +24,7 @@ model Client {
|
||||
bookings Booking[]
|
||||
invoices Invoice[]
|
||||
messages Message[] @relation("ClientMessages")
|
||||
pricing ClientPricing[]
|
||||
|
||||
@@map("clients")
|
||||
}
|
||||
@@ -27,69 +37,69 @@ model Pet {
|
||||
species String
|
||||
breed String?
|
||||
age Int?
|
||||
weight String? // e.g. "55 lbs"
|
||||
weight String?
|
||||
color String?
|
||||
tags String[] @default([])
|
||||
notes String? @default("")
|
||||
customFields Json?
|
||||
clientId String
|
||||
client Client @relation(fields: [clientId], references: [id], onDelete: Cascade)
|
||||
bookings Booking[] @relation("PetBookings")
|
||||
|
||||
@@map("pets")
|
||||
}
|
||||
|
||||
model Service {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
name String
|
||||
description String @default("")
|
||||
duration Int // minutes
|
||||
basePrice Float // dollars
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
name String
|
||||
description String @default("")
|
||||
duration Int
|
||||
basePrice Float
|
||||
|
||||
perClientPricing ClientPricing[]
|
||||
bookings Booking[]
|
||||
|
||||
@@map("services")
|
||||
}
|
||||
|
||||
model ClientPricing {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
price Float
|
||||
discountType String @default("none") // none, percentage, flat
|
||||
discountValue Float @default(0)
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
price Float
|
||||
discountType String @default("none")
|
||||
discountValue Float @default(0)
|
||||
|
||||
serviceId String
|
||||
service Service @relation(fields: [serviceId], references: [id], onDelete: Cascade)
|
||||
service Service @relation(fields: [serviceId], references: [id], onDelete: Cascade)
|
||||
clientId String
|
||||
client Client @relation(fields: [clientId], references: [id], onDelete: Cascade)
|
||||
client Client @relation(fields: [clientId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([serviceId, clientId])
|
||||
@@map("client_pricing")
|
||||
}
|
||||
|
||||
model Booking {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
startAt DateTime
|
||||
endAt DateTime
|
||||
status BookingStatus @default(scheduled)
|
||||
notes String? @default("")
|
||||
customFields Json?
|
||||
|
||||
clientId String
|
||||
client Client @relation(fields: [clientId], references: [id])
|
||||
serviceId String
|
||||
service Service @relation(fields: [serviceId], references: [id])
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
startAt DateTime
|
||||
endAt DateTime
|
||||
status BookingStatus @default(scheduled)
|
||||
notes String? @default("")
|
||||
customFields Json?
|
||||
clientId String
|
||||
client Client @relation(fields: [clientId], references: [id])
|
||||
serviceId String
|
||||
service Service @relation(fields: [serviceId], references: [id])
|
||||
assignedStaff String?
|
||||
priceOverride Float?
|
||||
petId String?
|
||||
pet Pet? @relation(fields: [petId], references: [id])
|
||||
invoice Invoice?
|
||||
|
||||
recurringRule Json? // { interval: "weekly" | "biweekly" | "monthly", count: Int, endDate: DateTime? }
|
||||
petId String?
|
||||
pet Pet? @relation("PetBookings", fields: [petId], references: [id])
|
||||
invoice Invoice? @relation(references: [id])
|
||||
recurringRule Json?
|
||||
|
||||
@@map("bookings")
|
||||
}
|
||||
@@ -103,24 +113,23 @@ enum BookingStatus {
|
||||
}
|
||||
|
||||
model Invoice {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
invoiceNumber String @unique
|
||||
dueDate DateTime
|
||||
status InvoiceStatus @default(draft)
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
invoiceNumber String @unique
|
||||
dueDate DateTime
|
||||
status InvoiceStatus @default(draft)
|
||||
stripePaymentIntentId String?
|
||||
subtotal Float @default(0)
|
||||
tax Float @default(0)
|
||||
total Float @default(0)
|
||||
notes String? @default("")
|
||||
subtotal Float @default(0)
|
||||
tax Float @default(0)
|
||||
total Float @default(0)
|
||||
notes String? @default("")
|
||||
|
||||
clientId String
|
||||
client Client @relation(fields: [clientId], references: [id])
|
||||
bookingId String?
|
||||
booking Booking? @relation(fields: [bookingId], references: [id])
|
||||
|
||||
items InvoiceItem[]
|
||||
bookingId String? @unique
|
||||
booking Booking? @relation(references: [id])
|
||||
invoiceItems InvoiceItem[]
|
||||
|
||||
@@map("invoices")
|
||||
}
|
||||
@@ -148,15 +157,15 @@ model InvoiceItem {
|
||||
}
|
||||
|
||||
model Message {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
readAt DateTime?
|
||||
content String
|
||||
isFromStaff Boolean @default(false)
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
readAt DateTime?
|
||||
content String
|
||||
isFromStaff Boolean @default(false)
|
||||
|
||||
clientId String
|
||||
client Client @relation("ClientMessages", fields: [clientId], references: [id])
|
||||
staffId String // staff member identifier
|
||||
staffId String
|
||||
|
||||
@@map("messages")
|
||||
}
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@ async function bootstrap() {
|
||||
SwaggerModule.setup('api/docs', app, document);
|
||||
|
||||
const port = process.env.PORT || 3000;
|
||||
await app.listen(port);
|
||||
console.log(`API running on http://localhost:${port}`);
|
||||
await app.listen(port, '0.0.0.0');
|
||||
console.log(`API running on http://0.0.0.0:${port}`);
|
||||
}
|
||||
bootstrap();
|
||||
|
||||
Reference in New Issue
Block a user