-- AlterTable
ALTER TABLE `files` ADD COLUMN `discussion_id` INTEGER NULL;

-- AlterTable
ALTER TABLE `notification_settings` MODIFY `type` ENUM('NEW_TRAINING_MODULE', 'TRAINING_REMINDER_24H', 'TRAINING_REMINDER_12H', 'TRAINING_REMINDER_1H', 'TRAINING_STARTED', 'TRAINING_CONTENT_UPDATE', 'TRAINING_FEEDBACK_REQUEST', 'ADD_TRAINING_SESSION', 'UPDATE_TRAINING_SESSION', 'UPDATE_ENROLLED_SESSION', 'NEW_COACHING_REQUEST', 'COACHING_REQUEST_TAKEN', 'COACHING_SCHEDULED', 'COACHING_REMINDER_24H', 'COACHING_REMINDER_12H', 'COACHING_REMINDER_1H', 'COACHING_STARTED', 'COACHING_FEEDBACK_REQUEST', 'STAKEHOLDER_COMMENT_ADDED', 'COACH_COMMENT_ADDED', 'UPDATE_COACHING_SESSION', 'NEW_TESTIMONIAL') NOT NULL;

-- AlterTable
ALTER TABLE `notifications` MODIFY `type` ENUM('NEW_TRAINING_MODULE', 'TRAINING_REMINDER_24H', 'TRAINING_REMINDER_12H', 'TRAINING_REMINDER_1H', 'TRAINING_STARTED', 'TRAINING_CONTENT_UPDATE', 'TRAINING_FEEDBACK_REQUEST', 'ADD_TRAINING_SESSION', 'UPDATE_TRAINING_SESSION', 'UPDATE_ENROLLED_SESSION', 'NEW_COACHING_REQUEST', 'COACHING_REQUEST_TAKEN', 'COACHING_SCHEDULED', 'COACHING_REMINDER_24H', 'COACHING_REMINDER_12H', 'COACHING_REMINDER_1H', 'COACHING_STARTED', 'COACHING_FEEDBACK_REQUEST', 'STAKEHOLDER_COMMENT_ADDED', 'COACH_COMMENT_ADDED', 'UPDATE_COACHING_SESSION', 'NEW_TESTIMONIAL') NOT NULL;

-- CreateTable
CREATE TABLE `testimonials` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `content` TEXT NOT NULL,
    `rating` INTEGER NOT NULL DEFAULT 5,
    `status` ENUM('PENDING', 'APPROVED', 'REJECTED') NOT NULL DEFAULT 'PENDING',
    `show_on_home` BOOLEAN NOT NULL DEFAULT false,
    `user_id` INTEGER NOT NULL,
    `reviewed_by_id` INTEGER NULL,
    `reviewed_at` DATETIME(3) NULL,
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updated_at` DATETIME(3) NOT NULL,

    INDEX `testimonials_user_id_idx`(`user_id`),
    INDEX `testimonials_status_idx`(`status`),
    INDEX `testimonials_show_on_home_idx`(`show_on_home`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateIndex
CREATE INDEX `files_discussion_id_idx` ON `files`(`discussion_id`);

-- AddForeignKey
ALTER TABLE `files` ADD CONSTRAINT `files_discussion_id_fkey` FOREIGN KEY (`discussion_id`) REFERENCES `discussions`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `testimonials` ADD CONSTRAINT `testimonials_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `testimonials` ADD CONSTRAINT `testimonials_reviewed_by_id_fkey` FOREIGN KEY (`reviewed_by_id`) REFERENCES `users`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
