246 lines
5.9 KiB
Text
246 lines
5.9 KiB
Text
generator client {
|
|
provider = "prisma-client"
|
|
output = "../src/generated/prisma"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
}
|
|
|
|
enum UserRole {
|
|
OWNER
|
|
CE_MANAGER
|
|
CE_MEMBER
|
|
TOURIST
|
|
ADMIN
|
|
}
|
|
|
|
enum CarbetStatus {
|
|
DRAFT
|
|
PUBLISHED
|
|
ARCHIVED
|
|
}
|
|
|
|
enum MediaType {
|
|
PHOTO
|
|
VIDEO
|
|
}
|
|
|
|
enum AvailabilityScope {
|
|
PUBLIC
|
|
CE_ONLY
|
|
}
|
|
|
|
enum AvailabilityBlockReason {
|
|
NONE
|
|
CE_BLOCKED
|
|
WEEKEND_BLOCKED
|
|
}
|
|
|
|
enum BookingStatus {
|
|
PENDING
|
|
CONFIRMED
|
|
CANCELLED
|
|
COMPLETED
|
|
}
|
|
|
|
enum PaymentStatus {
|
|
PENDING
|
|
AUTHORIZED
|
|
SUCCEEDED
|
|
FAILED
|
|
REFUNDED
|
|
}
|
|
|
|
enum SubscriptionStatus {
|
|
TRIAL
|
|
ACTIVE
|
|
PAST_DUE
|
|
CANCELED
|
|
}
|
|
|
|
model Organization {
|
|
id String @id @default(cuid())
|
|
name String
|
|
slug String @unique
|
|
description String?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
members User[]
|
|
|
|
@@index([name])
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(cuid())
|
|
email String @unique
|
|
passwordHash String
|
|
firstName String
|
|
lastName String
|
|
phone String?
|
|
role UserRole
|
|
organizationId String?
|
|
avatarUrl String?
|
|
isActive Boolean @default(true)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
organization Organization? @relation(fields: [organizationId], references: [id], onDelete: SetNull)
|
|
carbets Carbet[] @relation("CarbetOwner")
|
|
bookings Booking[] @relation("BookingTenant")
|
|
reviews Review[] @relation("ReviewAuthor")
|
|
subscriptions Subscription[]
|
|
|
|
@@index([organizationId])
|
|
@@index([role])
|
|
}
|
|
|
|
model Carbet {
|
|
id String @id @default(cuid())
|
|
ownerId String
|
|
title String
|
|
slug String @unique
|
|
description String
|
|
river String
|
|
latitude Decimal @db.Decimal(9, 6)
|
|
longitude Decimal @db.Decimal(9, 6)
|
|
embarkPoint String
|
|
pirogueDurationMin Int
|
|
capacity Int
|
|
status CarbetStatus @default(DRAFT)
|
|
lastBookedAt DateTime?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
owner User @relation("CarbetOwner", fields: [ownerId], references: [id], onDelete: Restrict)
|
|
amenities CarbetAmenity[]
|
|
media Media[]
|
|
availabilities Availability[]
|
|
bookings Booking[]
|
|
reviews Review[]
|
|
subscriptions Subscription[]
|
|
|
|
@@index([ownerId])
|
|
@@index([status])
|
|
@@index([river])
|
|
}
|
|
|
|
model Amenity {
|
|
id String @id @default(cuid())
|
|
key String @unique
|
|
label String
|
|
description String?
|
|
createdAt DateTime @default(now())
|
|
|
|
carbets CarbetAmenity[]
|
|
}
|
|
|
|
model CarbetAmenity {
|
|
carbetId String
|
|
amenityId String
|
|
|
|
carbet Carbet @relation(fields: [carbetId], references: [id], onDelete: Cascade)
|
|
amenity Amenity @relation(fields: [amenityId], references: [id], onDelete: Cascade)
|
|
|
|
@@id([carbetId, amenityId])
|
|
@@index([amenityId])
|
|
}
|
|
|
|
model Media {
|
|
id String @id @default(cuid())
|
|
carbetId String
|
|
type MediaType
|
|
s3Key String
|
|
s3Url String
|
|
sortOrder Int @default(0)
|
|
createdAt DateTime @default(now())
|
|
|
|
carbet Carbet @relation(fields: [carbetId], references: [id], onDelete: Cascade)
|
|
|
|
@@index([carbetId, sortOrder])
|
|
}
|
|
|
|
model Availability {
|
|
id String @id @default(cuid())
|
|
carbetId String
|
|
startDate DateTime
|
|
endDate DateTime
|
|
scope AvailabilityScope @default(PUBLIC)
|
|
blockReason AvailabilityBlockReason @default(NONE)
|
|
isAvailable Boolean @default(true)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
carbet Carbet @relation(fields: [carbetId], references: [id], onDelete: Cascade)
|
|
|
|
@@index([carbetId])
|
|
@@index([scope, blockReason])
|
|
@@index([startDate, endDate])
|
|
}
|
|
|
|
model Booking {
|
|
id String @id @default(cuid())
|
|
carbetId String
|
|
tenantId String
|
|
startDate DateTime
|
|
endDate DateTime
|
|
guestCount Int
|
|
status BookingStatus @default(PENDING)
|
|
amount Decimal @db.Decimal(10, 2)
|
|
currency String @default("EUR")
|
|
paymentStatus PaymentStatus @default(PENDING)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
carbet Carbet @relation(fields: [carbetId], references: [id], onDelete: Restrict)
|
|
tenant User @relation("BookingTenant", fields: [tenantId], references: [id], onDelete: Restrict)
|
|
|
|
review Review?
|
|
|
|
@@index([carbetId])
|
|
@@index([tenantId])
|
|
@@index([status, paymentStatus])
|
|
@@index([startDate, endDate])
|
|
}
|
|
|
|
model Subscription {
|
|
id String @id @default(cuid())
|
|
ownerId String
|
|
carbetId String
|
|
provider String
|
|
providerSubId String? @unique
|
|
status SubscriptionStatus @default(TRIAL)
|
|
startedAt DateTime @default(now())
|
|
renewedAt DateTime?
|
|
canceledAt DateTime?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
owner User @relation(fields: [ownerId], references: [id], onDelete: Restrict)
|
|
carbet Carbet @relation(fields: [carbetId], references: [id], onDelete: Cascade)
|
|
|
|
@@index([ownerId])
|
|
@@index([carbetId])
|
|
@@index([status])
|
|
}
|
|
|
|
model Review {
|
|
id String @id @default(cuid())
|
|
bookingId String @unique
|
|
carbetId String
|
|
authorId String
|
|
rating Int
|
|
comment String?
|
|
hostResponse String?
|
|
hostRespondedAt DateTime?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
booking Booking @relation(fields: [bookingId], references: [id], onDelete: Cascade)
|
|
carbet Carbet @relation(fields: [carbetId], references: [id], onDelete: Restrict)
|
|
author User @relation("ReviewAuthor", fields: [authorId], references: [id], onDelete: Restrict)
|
|
|
|
@@index([carbetId])
|
|
@@index([authorId])
|
|
}
|