From 8e28e2c71670cdb6c25743769bb34861af5fec12 Mon Sep 17 00:00:00 2001 From: Muhammad Zhafran Ilham Date: Tue, 23 Jun 2026 19:04:03 +0700 Subject: [PATCH] feat: menambahkan prisma migration untuk penambahan mentor, notification, certif uuid constraint, dan remove max_members --- .../migration.sql | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 prisma/migrations/20260623115332_add_mentor_notification_and_certificate_uuid_unique_constraint_remove_max_members/migration.sql diff --git a/prisma/migrations/20260623115332_add_mentor_notification_and_certificate_uuid_unique_constraint_remove_max_members/migration.sql b/prisma/migrations/20260623115332_add_mentor_notification_and_certificate_uuid_unique_constraint_remove_max_members/migration.sql new file mode 100644 index 0000000..ee0d044 --- /dev/null +++ b/prisma/migrations/20260623115332_add_mentor_notification_and_certificate_uuid_unique_constraint_remove_max_members/migration.sql @@ -0,0 +1,43 @@ +/* + Warnings: + + - You are about to drop the column `max_members` on the `project` table. All the data in the column will be lost. + - A unique constraint covering the columns `[uuid]` on the table `certificate` will be added. If there are existing duplicate values, this will fail. + - The required column `uuid` was added to the `certificate` table with a prisma-level default value. This is not possible if the table is not empty. Please add this column as optional, then populate it before making it required. + +*/ +-- AlterTable +ALTER TABLE `admin` MODIFY `role` ENUM('admin', 'mentor', 'intern') NOT NULL DEFAULT 'admin'; + +-- AlterTable +ALTER TABLE `certificate` ADD COLUMN `uuid` VARCHAR(36) NOT NULL; + +-- AlterTable +ALTER TABLE `project` DROP COLUMN `max_members`; + +-- AlterTable +ALTER TABLE `user` MODIFY `role` ENUM('admin', 'mentor', 'intern') NOT NULL DEFAULT 'intern'; + +-- CreateTable +CREATE TABLE `notification` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `id_user` INTEGER NULL, + `id_admin` INTEGER NULL, + `title` VARCHAR(255) NOT NULL, + `message` TEXT NOT NULL, + `is_read` BOOLEAN NOT NULL DEFAULT false, + `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), + + INDEX `notification_id_user_idx`(`id_user`), + INDEX `notification_id_admin_idx`(`id_admin`), + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateIndex +CREATE UNIQUE INDEX `certificate_uuid_key` ON `certificate`(`uuid`); + +-- AddForeignKey +ALTER TABLE `notification` ADD CONSTRAINT `notification_id_user_fkey` FOREIGN KEY (`id_user`) REFERENCES `user`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `notification` ADD CONSTRAINT `notification_id_admin_fkey` FOREIGN KEY (`id_admin`) REFERENCES `admin`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;