Files
ospab.host/ospabhost/backend/prisma/schema.prisma
2025-09-18 10:18:45 +03:00

64 lines
1.7 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 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"
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
model User {
id Int @id @default(autoincrement())
username String
email String @unique
password String
createdAt DateTime @default(now())
plans Plan[]
operator Int @default(0) // Добавляем новую колонку operator
}
model Plan {
id Int @id @default(autoincrement())
name String @unique
price Float
description String?
isCustom Boolean @default(false)
createdAt DateTime @default(now())
userId Int
owner User @relation(fields: [userId], references: [id])
services Service[]
}
model Service {
id Int @id @default(autoincrement())
name String @unique
price Float
planId Int?
plan Plan? @relation(fields: [planId], references: [id])
}
model Ticket {
id Int @id @default(autoincrement())
title String
message String
userId Int
status String @default("open")
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
responses Response[] // связь
// Если нужна связь с User:
// user User @relation(fields: [userId], references: [id])
}
model Response {
id Int @id @default(autoincrement())
ticketId Int
operatorId Int
message String
createdAt DateTime @default(now())
ticket Ticket @relation(fields: [ticketId], references: [id]) // <-- обратная связь
}