сделана система тикетов

This commit is contained in:
Georgiy Syralev
2025-09-18 10:18:45 +03:00
parent d1dfa31478
commit 97711d8a4c
2 changed files with 49 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
-- CreateTable
CREATE TABLE `Ticket` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`title` VARCHAR(191) NOT NULL,
`message` VARCHAR(191) NOT NULL,
`userId` INTEGER NOT NULL,
`status` VARCHAR(191) NOT NULL DEFAULT 'open',
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
`updatedAt` DATETIME(3) NOT NULL,
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `Response` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`ticketId` INTEGER NOT NULL,
`operatorId` INTEGER NOT NULL,
`message` VARCHAR(191) NOT NULL,
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- AddForeignKey
ALTER TABLE `Response` ADD CONSTRAINT `Response_ticketId_fkey` FOREIGN KEY (`ticketId`) REFERENCES `Ticket`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@@ -38,4 +38,27 @@ model Service {
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]) // <-- обратная связь
}