// This is your Prisma schema file, // learn more about it in the docs: https://pris.ly/d/prisma-schema generator client { provider = "prisma-client-js" // https://github.com/prisma/prisma-client-js/issues/616#issuecomment-616107821 binaryTargets = ["native", "darwin", "debian-openssl-1.1.x"] } datasource db { provider = "postgresql" url = env("DATABASE_URL") } model User { id Int @id @default(autoincrement()) email String? @unique username String? @unique password String? phone String? @unique fullname String? dob DateTime? gender Gender @default(Female) bookings Booking[] language Language @default(vi) Slots Slot[] Comments Comment[] created_at DateTime @default(now()) @db.Timestamptz(3) updated_at DateTime @updatedAt @db.Timestamptz(3) deleted_at DateTime? @db.Timestamptz(3) Like Like[] Vote Vote[] @@index([id, email]) } model Booking { id Int @id @default(autoincrement()) path String? image String? public Boolean @default(true) user User @relation(fields: [user_id], references: [id], onUpdate: Cascade, onDelete: Cascade) user_id Int status BookingStatus @default(pending) slot Slot @relation(fields: [slot_id], references: [id]) slot_id Int start_at DateTime @db.Timestamptz(3) end_at DateTime @db.Timestamptz(3) owner String license_plates String contact String pricing Int? booking_type BookingType? @default(All) slot_type SlotType? @default(Car) created_at DateTime @default(now()) @db.Timestamptz(3) updated_at DateTime @updatedAt @db.Timestamptz(3) deleted_at DateTime? @db.Timestamptz(3) @@index([user_id, id]) } model Slot { id Int @id @default(autoincrement()) name String lat Float lng Float images String[] @default([]) address String district String ward String city String destination String? phone String? total Int empty Int published Boolean @default(false) tenant Tenant? @relation(fields: [tenantId], references: [id]) tenantId Int? user User? @relation(fields: [userId], references: [id]) userId Int? distance Float? duration Float? directions Json? slot_type SlotType? @default(Car) alow_booking_type BookingType? @default(All) open String? @db.VarChar(5) close String? @db.VarChar(5) created_at DateTime @default(now()) @db.Timestamptz(3) updated_at DateTime @updatedAt @db.Timestamptz(3) deleted_at DateTime? @db.Timestamptz(3) pricing_per_hour Int @default(0) Bookings Booking[] Comments Comment[] Vote Vote[] @@index([id]) } model Admin { id Int @id @default(autoincrement()) username String @unique password String password_confirmation String? street String? city String? province String? first_name String last_name String phone String dob DateTime? language Language @default(vi) last_login_at DateTime? current_login_at DateTime? last_login_failed_at DateTime? consecutive_login_penalty Int @default(0) avatarUrl String? active Boolean @default(true) last_lockout_at DateTime? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } model Tenant { id Int @id @default(autoincrement()) email String? @unique username String @unique password String password_confirmation String? street String? city String? province String? postal_code String? first_name String last_name String phone String language Language @default(vi) last_login_at DateTime? current_login_at DateTime? last_login_failed_at DateTime? consecutive_login_penalty Int @default(0) avatarUrl String? active Boolean @default(true) last_lockout_at DateTime? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt Slots Slot[] Comments Comment[] } model File { id Int @id @default(autoincrement()) path String slot_id Int? user_id Int? size Int mine_type String? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt deletedAt DateTime? } model History { id Int @id @default(autoincrement()) } model Comment { id Int @id @default(autoincrement()) slot_id Int content String? tenant Tenant? @relation(fields: [tenantId], references: [id]) tenantId Int? user User? @relation(fields: [userId], references: [id]) userId Int? slot Slot @relation(fields: [slot_id], references: [id]) likes Like[] } model Like { id Int @id @default(autoincrement()) Comment Comment @relation(fields: [commentId], references: [id]) commentId Int user User? @relation(fields: [userId], references: [id]) userId Int? } model Vote { id Int @id @default(autoincrement()) slot Slot @relation(fields: [slot_id], references: [id]) slot_id Int user User? @relation(fields: [userId], references: [id]) userId Int? source Int @default(0) type Int @default(0) } enum Language { vi en } enum Gender { Male Female LGBT } enum BookingStatus { done pending reject cancel out } enum SlotType { Car Mortorbike Orther } enum BookingType { Fulltime Parttime All }