/*
  Warnings:

  - You are about to drop the `training_sessoin` table. If the table is not empty, all the data it contains will be lost.

*/
-- DropForeignKey
ALTER TABLE `student_examination` DROP FOREIGN KEY `student_examination_training_session_id_fkey`;

-- DropForeignKey
ALTER TABLE `training_sessoin` DROP FOREIGN KEY `training_sessoin_lesson_id_fkey`;

-- DropForeignKey
ALTER TABLE `training_sessoin` DROP FOREIGN KEY `training_sessoin_user_id_fkey`;

-- DropTable
DROP TABLE `training_sessoin`;

-- CreateTable
CREATE TABLE `training_session` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `lesson_id` INTEGER NOT NULL,
    `user_id` INTEGER NOT NULL,
    `status` ENUM('finished', 'inprogress') NOT NULL,
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updated_at` DATETIME(3) NOT NULL,

    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- AddForeignKey
ALTER TABLE `student_examination` ADD CONSTRAINT `student_examination_training_session_id_fkey` FOREIGN KEY (`training_session_id`) REFERENCES `training_session`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `training_session` ADD CONSTRAINT `training_session_lesson_id_fkey` FOREIGN KEY (`lesson_id`) REFERENCES `lesson`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

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