new table for settings and store blocked date there;

non admins can't enter avs before the blocked date
new table for survey
This commit is contained in:
Dobromir Popov
2024-06-16 23:33:49 +03:00
parent 901d577b9c
commit 8ca2000ee4
12 changed files with 205 additions and 50 deletions

View File

@ -0,0 +1,9 @@
-- CreateTable
CREATE TABLE `Settings` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`key` VARCHAR(191) NOT NULL,
`value` VARCHAR(191) NOT NULL,
`description` VARCHAR(191) NULL,
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

View File

@ -0,0 +1,10 @@
/*
Warnings:
- The primary key for the `settings` table will be changed. If it partially fails, the table could be left without primary key constraint.
- You are about to drop the column `id` on the `settings` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE `Settings`
DROP PRIMARY KEY,
DROP COLUMN `id`,
ADD PRIMARY KEY (`key`);

View File

@ -0,0 +1,19 @@
-- AlterTable
ALTER TABLE `message` ADD COLUMN `answer` VARCHAR(191) NULL,
ADD COLUMN `answerDate` DATETIME(3) NULL,
ADD COLUMN `shownDate` DATETIME(3) NULL,
ADD COLUMN `surveyId` INTEGER NULL;
-- CreateTable
CREATE TABLE `Survey` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`content` VARCHAR(191) NOT NULL,
`answers` JSON NULL,
`publicFrom` DATETIME(3) NULL,
`publicUntil` DATETIME(3) NULL,
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- AddForeignKey
ALTER TABLE `Message` ADD CONSTRAINT `Message_surveyId_fkey` FOREIGN KEY (`surveyId`) REFERENCES `Survey`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;

View File

@ -264,6 +264,15 @@ enum MessageType {
InApp
}
model Survey {
id Int @id @default(autoincrement())
content String
answers Json?
messages Message[]
publicFrom DateTime?
publicUntil DateTime?
}
model Message {
id Int @id @default(autoincrement())
publisher Publisher @relation(fields: [publisherId], references: [id])
@ -274,6 +283,12 @@ model Message {
isPublic Boolean @default(false)
type MessageType @default(Email)
publicUntil DateTime?
shownDate DateTime?
answer String?
answerDate DateTime?
Survey Survey? @relation(fields: [surveyId], references: [id])
surveyId Int?
}
enum EventLogType {
@ -348,3 +363,9 @@ model VerificationToken {
@@unique([identifier, token])
}
model Settings {
key String @id
value String
description String?
}