-- CreateTable
CREATE TABLE `db_users` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(191) NULL,
    `email` VARCHAR(255) NOT NULL,
    `password` VARCHAR(255) NULL,
    `googleId` VARCHAR(255) NULL,
    `mobile` VARCHAR(16) NULL,
    `profileUrl` VARCHAR(191) NULL,
    `role` ENUM('SUPER_ADMIN', 'ADMIN', 'SCHOOL_ADMIN', 'TEACHER', 'INDIVIDUAL_TEACHER', 'STUDENT', 'INDIVIDUAL_STUDENT') NOT NULL,
    `status` ENUM('ACTIVE', 'INACTIVE') NOT NULL DEFAULT 'ACTIVE',
    `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updatedAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `createdBy` INTEGER NULL,
    `updatedBy` INTEGER NULL,

    UNIQUE INDEX `db_users_email_key`(`email`),
    UNIQUE INDEX `db_users_googleId_key`(`googleId`),
    UNIQUE INDEX `db_users_mobile_key`(`mobile`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `db_courses` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `title` VARCHAR(255) NOT NULL,
    `slug` VARCHAR(255) NOT NULL,
    `shortDescription` TEXT NULL,
    `description` TEXT NULL,
    `bannerUrl` VARCHAR(255) NULL,
    `thumbnailUrl` VARCHAR(255) NULL,
    `isPublished` BOOLEAN NOT NULL DEFAULT false,
    `status` ENUM('ACTIVE', 'INACTIVE') NOT NULL DEFAULT 'ACTIVE',
    `index` INTEGER NULL,
    `price` VARCHAR(255) NULL,
    `studentPrice` VARCHAR(255) NULL,
    `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updatedAt` DATETIME(3) NOT NULL,
    `createdBy` INTEGER NULL,
    `updatedBy` INTEGER NULL,

    UNIQUE INDEX `db_courses_slug_key`(`slug`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `db_modules` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `title` VARCHAR(255) NOT NULL,
    `slug` VARCHAR(255) NOT NULL,
    `description` TEXT NULL,
    `bannerUrl` VARCHAR(255) NULL,
    `thumbnailUrl` VARCHAR(255) NULL,
    `isPublished` BOOLEAN NOT NULL DEFAULT false,
    `status` ENUM('ACTIVE', 'INACTIVE') NOT NULL DEFAULT 'ACTIVE',
    `deleted` BOOLEAN NOT NULL DEFAULT false,
    `index` INTEGER NULL,
    `courseId` INTEGER NOT NULL,
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updated_at` DATETIME(3) NOT NULL,
    `deleted_at` DATETIME(3) NOT NULL,
    `created_by` INTEGER NULL,
    `updated_by` INTEGER NULL,
    `deleted_by` INTEGER NULL,

    UNIQUE INDEX `db_modules_slug_key`(`slug`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `db_topics` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `title` VARCHAR(255) NOT NULL,
    `slug` VARCHAR(255) NOT NULL,
    `description` TEXT NULL,
    `bannerUrl` VARCHAR(255) NULL,
    `thumbnailUrl` VARCHAR(255) NULL,
    `isPublished` BOOLEAN NOT NULL DEFAULT false,
    `status` ENUM('ACTIVE', 'INACTIVE') NOT NULL DEFAULT 'ACTIVE',
    `index` INTEGER NULL,
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updated_at` DATETIME(3) NOT NULL,
    `created_by` INTEGER NULL,
    `updated_by` INTEGER NULL,
    `moduleId` INTEGER NOT NULL,

    UNIQUE INDEX `db_topics_slug_key`(`slug`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `db_activities` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `title` VARCHAR(255) NOT NULL,
    `type` VARCHAR(255) NULL,
    `details` TEXT NULL,
    `isPublished` BOOLEAN NOT NULL DEFAULT false,
    `bannerUrl` VARCHAR(255) NULL,
    `thumbnailUrl` VARCHAR(255) NULL,
    `file` VARCHAR(255) NULL,
    `status` ENUM('ACTIVE', 'INACTIVE') NOT NULL DEFAULT 'ACTIVE',
    `index` INTEGER NULL DEFAULT 1,
    `resourcesType` VARCHAR(255) NULL,
    `isTeacherDownload` BOOLEAN NOT NULL DEFAULT false,
    `isStudentDownload` BOOLEAN NOT NULL DEFAULT false,
    `topicId` INTEGER NOT NULL,
    `activitesTypeId` INTEGER NOT NULL,
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updated_at` DATETIME(3) NOT NULL,
    `created_by` INTEGER NULL,
    `updated_by` INTEGER NULL,

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

-- CreateTable
CREATE TABLE `db_activites_quiz` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `question` TEXT NULL,
    `difficultyLevel` VARCHAR(255) NULL,
    `mark` VARCHAR(255) NULL,
    `explaination` TEXT NULL,
    `bloomTaxonomy` VARCHAR(255) NULL,
    `isPublished` BOOLEAN NOT NULL DEFAULT false,
    `status` ENUM('ACTIVE', 'INACTIVE') NOT NULL DEFAULT 'ACTIVE',
    `index` INTEGER NULL DEFAULT 1,
    `questionTime` DOUBLE NULL,
    `answerMethod` VARCHAR(255) NULL,
    `quizType` VARCHAR(10) NULL DEFAULT 'QUIZ',
    `activityId` INTEGER NOT NULL,
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updated_at` DATETIME(3) NOT NULL,
    `created_by` INTEGER NULL,
    `updated_by` INTEGER NULL,

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

-- CreateTable
CREATE TABLE `db_activites_quiz_option` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `choice` TEXT NULL,
    `answer` BOOLEAN NOT NULL DEFAULT false,
    `isPublished` BOOLEAN NOT NULL DEFAULT false,
    `status` ENUM('ACTIVE', 'INACTIVE') NOT NULL DEFAULT 'ACTIVE',
    `index` INTEGER NULL DEFAULT 1,
    `quizId` INTEGER NOT NULL,
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updated_at` DATETIME(3) NOT NULL,
    `created_by` INTEGER NULL,
    `updated_by` INTEGER NULL,

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

-- CreateTable
CREATE TABLE `db_activities_type` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `title` VARCHAR(255) NOT NULL,
    `type` VARCHAR(255) NULL,
    `bannerUrl` VARCHAR(255) NULL,
    `thumbnailUrl` VARCHAR(255) NULL,
    `description` TEXT NULL,
    `isVisibleTeacher` BOOLEAN NOT NULL DEFAULT false,
    `isPublished` BOOLEAN NOT NULL DEFAULT false,
    `index` INTEGER NULL,
    `status` ENUM('ACTIVE', 'INACTIVE') NOT NULL DEFAULT 'ACTIVE',
    `created_by` INTEGER NULL,
    `updated_by` INTEGER 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;

-- CreateTable
CREATE TABLE `db_library_modules` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `title` VARCHAR(255) NOT NULL,
    `slug` VARCHAR(255) NOT NULL,
    `description` TEXT NULL,
    `bannerUrl` VARCHAR(255) NULL,
    `thumbnailUrl` VARCHAR(255) NULL,
    `isPublished` BOOLEAN NOT NULL DEFAULT false,
    `index` INTEGER NULL,
    `status` ENUM('ACTIVE', 'INACTIVE') NOT NULL DEFAULT 'ACTIVE',
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updated_at` DATETIME(3) NOT NULL,
    `created_by` INTEGER NULL,
    `updated_by` INTEGER NULL,

    UNIQUE INDEX `db_library_modules_slug_key`(`slug`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `db_library_topics` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `title` VARCHAR(255) NOT NULL,
    `slug` VARCHAR(255) NOT NULL,
    `description` TEXT NULL,
    `isPublished` BOOLEAN NOT NULL DEFAULT false,
    `bannerUrl` VARCHAR(255) NULL,
    `thumbnailUrl` VARCHAR(255) NULL,
    `status` ENUM('ACTIVE', 'INACTIVE') NOT NULL DEFAULT 'ACTIVE',
    `index` INTEGER NULL DEFAULT 1,
    `moduleId` INTEGER NOT NULL,
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updated_at` DATETIME(3) NOT NULL,
    `created_by` INTEGER NULL,
    `updated_by` INTEGER NULL,

    UNIQUE INDEX `db_library_topics_slug_key`(`slug`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `db_library_activites` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `title` VARCHAR(255) NOT NULL,
    `type` VARCHAR(255) NULL,
    `details` TEXT NULL,
    `isPublished` BOOLEAN NOT NULL DEFAULT false,
    `bannerUrl` VARCHAR(255) NULL,
    `thumbnailUrl` VARCHAR(255) NULL,
    `file` VARCHAR(255) NULL,
    `status` ENUM('ACTIVE', 'INACTIVE') NOT NULL DEFAULT 'ACTIVE',
    `index` INTEGER NULL DEFAULT 1,
    `resourcesType` VARCHAR(255) NULL,
    `isTeacherDownload` BOOLEAN NOT NULL DEFAULT false,
    `isStudentDownload` BOOLEAN NOT NULL DEFAULT false,
    `topicId` INTEGER NOT NULL,
    `activitesTypeId` INTEGER NOT NULL,
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updated_at` DATETIME(3) NOT NULL,
    `created_by` INTEGER NULL,
    `updated_by` INTEGER NULL,

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

-- CreateTable
CREATE TABLE `db_library_activites_quiz` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `question` TEXT NULL,
    `difficultyLevel` VARCHAR(255) NULL,
    `mark` VARCHAR(255) NULL,
    `explaination` TEXT NULL,
    `bloomTaxonomy` VARCHAR(255) NULL,
    `isPublished` BOOLEAN NOT NULL DEFAULT false,
    `status` ENUM('ACTIVE', 'INACTIVE') NOT NULL DEFAULT 'ACTIVE',
    `index` INTEGER NULL DEFAULT 1,
    `questionTime` DOUBLE NULL,
    `answerMethod` VARCHAR(255) NULL,
    `quizType` VARCHAR(10) NULL DEFAULT 'QUIZ',
    `activityId` INTEGER NOT NULL,
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updated_at` DATETIME(3) NOT NULL,
    `created_by` INTEGER NULL,
    `updated_by` INTEGER NULL,

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

-- CreateTable
CREATE TABLE `db_library_activites_quiz_option` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `choice` TEXT NULL,
    `answer` BOOLEAN NOT NULL DEFAULT false,
    `isPublished` BOOLEAN NOT NULL DEFAULT false,
    `status` ENUM('ACTIVE', 'INACTIVE') NOT NULL DEFAULT 'ACTIVE',
    `index` INTEGER NULL DEFAULT 1,
    `quizId` INTEGER NOT NULL,
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updated_at` DATETIME(3) NOT NULL,
    `created_by` INTEGER NULL,
    `updated_by` INTEGER NULL,

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

-- CreateTable
CREATE TABLE `db_teacher_modules` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `title` VARCHAR(255) NOT NULL,
    `slug` VARCHAR(255) NOT NULL,
    `description` TEXT NULL,
    `bannerUrl` VARCHAR(255) NULL,
    `thumbnailUrl` VARCHAR(255) NULL,
    `isPublished` BOOLEAN NOT NULL DEFAULT false,
    `status` ENUM('ACTIVE', 'INACTIVE') NOT NULL DEFAULT 'ACTIVE',
    `deleted` BOOLEAN NOT NULL DEFAULT false,
    `index` INTEGER NULL,
    `courseId` INTEGER NOT NULL,
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updated_at` DATETIME(3) NOT NULL,
    `deleted_at` DATETIME(3) NOT NULL,
    `created_by` INTEGER NULL,
    `updated_by` INTEGER NULL,
    `deleted_by` INTEGER NULL,

    UNIQUE INDEX `db_teacher_modules_slug_key`(`slug`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `db_teacher_topics` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `title` VARCHAR(255) NOT NULL,
    `slug` VARCHAR(255) NOT NULL,
    `description` TEXT NULL,
    `bannerUrl` VARCHAR(255) NULL,
    `thumbnailUrl` VARCHAR(255) NULL,
    `isPublished` BOOLEAN NOT NULL DEFAULT false,
    `status` ENUM('ACTIVE', 'INACTIVE') NOT NULL DEFAULT 'ACTIVE',
    `index` INTEGER NULL,
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updated_at` DATETIME(3) NOT NULL,
    `created_by` INTEGER NULL,
    `updated_by` INTEGER NULL,
    `moduleId` INTEGER NULL,
    `teacherModuleId` INTEGER NULL,

    UNIQUE INDEX `db_teacher_topics_slug_key`(`slug`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `db_teacher_activites` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `title` VARCHAR(255) NOT NULL,
    `type` VARCHAR(255) NULL,
    `details` TEXT NULL,
    `isPublished` BOOLEAN NOT NULL DEFAULT false,
    `bannerUrl` VARCHAR(255) NULL,
    `thumbnailUrl` VARCHAR(255) NULL,
    `file` VARCHAR(255) NULL,
    `status` ENUM('ACTIVE', 'INACTIVE') NOT NULL DEFAULT 'ACTIVE',
    `index` INTEGER NULL DEFAULT 1,
    `resourcesType` VARCHAR(255) NULL,
    `isTeacherDownload` BOOLEAN NOT NULL DEFAULT false,
    `isStudentDownload` BOOLEAN NOT NULL DEFAULT false,
    `addedType` VARCHAR(191) NULL DEFAULT 'ACTIVITY',
    `topicId` INTEGER NULL,
    `courseId` INTEGER NULL,
    `teacherTopicId` INTEGER NULL,
    `activitesTypeId` INTEGER NOT NULL,
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updated_at` DATETIME(3) NOT NULL,
    `created_by` INTEGER NULL,
    `updated_by` INTEGER NULL,

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

-- CreateTable
CREATE TABLE `db_teacher_activites_quiz` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `question` TEXT NULL,
    `difficultyLevel` VARCHAR(255) NULL,
    `mark` VARCHAR(255) NULL,
    `explaination` TEXT NULL,
    `bloomTaxonomy` VARCHAR(255) NULL,
    `isPublished` BOOLEAN NOT NULL DEFAULT false,
    `status` ENUM('ACTIVE', 'INACTIVE') NOT NULL DEFAULT 'ACTIVE',
    `index` INTEGER NULL DEFAULT 1,
    `questionTime` DOUBLE NULL,
    `answerMethod` VARCHAR(255) NULL,
    `quizType` VARCHAR(10) NULL DEFAULT 'QUIZ',
    `activityId` INTEGER NOT NULL,
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updated_at` DATETIME(3) NOT NULL,
    `created_by` INTEGER NULL,
    `updated_by` INTEGER NULL,

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

-- CreateTable
CREATE TABLE `db_teacher_activites_quiz_option` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `choice` TEXT NULL,
    `answer` BOOLEAN NOT NULL DEFAULT false,
    `isPublished` BOOLEAN NOT NULL DEFAULT false,
    `status` ENUM('ACTIVE', 'INACTIVE') NOT NULL DEFAULT 'ACTIVE',
    `index` INTEGER NULL DEFAULT 1,
    `quizId` INTEGER NOT NULL,
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updated_at` DATETIME(3) NOT NULL,
    `created_by` INTEGER NULL,
    `updated_by` INTEGER NULL,

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

-- CreateTable
CREATE TABLE `db_schools` (
    `id` INTEGER NOT NULL,
    `school_name` VARCHAR(255) NOT NULL,
    `school_email` VARCHAR(255) NOT NULL,
    `school_phone` VARCHAR(20) NULL,
    `city` VARCHAR(100) NULL,
    `state` VARCHAR(100) NULL,
    `country` VARCHAR(100) NULL,
    `postal_code` VARCHAR(20) NULL,
    `thumbnailUrl` VARCHAR(255) NULL,
    `bannerUrl` VARCHAR(255) NULL,
    `description` TEXT NULL,
    `address_1` TEXT NULL,
    `address_2` TEXT NULL,
    `status` ENUM('ACTIVE', 'INACTIVE') NOT NULL DEFAULT 'ACTIVE',
    `isPublished` BOOLEAN NOT NULL DEFAULT false,
    `deleted` BOOLEAN NOT NULL DEFAULT false,
    `blocked` BOOLEAN NOT NULL DEFAULT false,
    `join_date` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updated_at` DATETIME(3) NOT NULL,
    `created_by` INTEGER NULL,
    `updated_by` INTEGER NULL,

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

-- CreateTable
CREATE TABLE `db_schools_course` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `numberOfStudents` INTEGER NULL,
    `numberOfTeachers` INTEGER NULL,
    `schoolId` INTEGER NOT NULL,
    `courseId` INTEGER NOT NULL,
    `status` ENUM('ACTIVE', 'INACTIVE') NOT NULL DEFAULT 'ACTIVE',
    `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updatedAt` DATETIME(3) NOT NULL,
    `createdBy` INTEGER NULL,
    `updatedBy` INTEGER NULL,

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

-- CreateTable
CREATE TABLE `db_schools_course_history` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `numberOfStudents` INTEGER NULL,
    `numberOfTeachers` INTEGER NULL,
    `schoolId` INTEGER NOT NULL,
    `schoolCourseId` INTEGER NOT NULL,
    `courseId` INTEGER NOT NULL,
    `status` ENUM('ACTIVE', 'INACTIVE') NOT NULL DEFAULT 'ACTIVE',
    `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updatedAt` DATETIME(3) NOT NULL,
    `createdBy` INTEGER NULL,
    `updatedBy` INTEGER NULL,

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

-- CreateTable
CREATE TABLE `db_schools_activation_code` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `activationCode` VARCHAR(191) NULL,
    `classCode` VARCHAR(191) NULL,
    `type` VARCHAR(191) NULL,
    `used` BOOLEAN NULL DEFAULT false,
    `usedAt` DATETIME(3) NULL,
    `userExpiryDate` DATETIME(3) NULL,
    `courseExpiryDate` DATETIME(3) NULL,
    `schoolId` INTEGER NOT NULL,
    `schoolCourseId` INTEGER NOT NULL,
    `courseId` INTEGER NOT NULL,
    `usedBy` INTEGER NULL,
    `status` ENUM('ACTIVE', 'INACTIVE') NOT NULL DEFAULT 'ACTIVE',
    `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updatedAt` DATETIME(3) NOT NULL,
    `createdBy` INTEGER NULL,
    `updatedBy` INTEGER NULL,

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

-- CreateTable
CREATE TABLE `db_students` (
    `id` INTEGER NOT NULL,
    `email` VARCHAR(255) NULL,
    `firstname` VARCHAR(255) NULL,
    `lastname` VARCHAR(255) NULL,
    `fullname` VARCHAR(255) NULL,
    `image` VARCHAR(255) NULL,
    `country_code_id` INTEGER NULL,
    `contact` VARCHAR(11) NULL,
    `gender` VARCHAR(11) NULL,
    `address_1` TEXT NULL,
    `address_2` TEXT NULL,
    `city` VARCHAR(255) NULL,
    `state` VARCHAR(255) NULL,
    `country` VARCHAR(255) NULL,
    `dob` DATETIME(3) NULL,
    `userId` INTEGER NULL,
    `schoolId` INTEGER NULL,
    `status` ENUM('ACTIVE', 'INACTIVE') NOT NULL DEFAULT 'ACTIVE',
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updated_at` DATETIME(3) NOT NULL,
    `created_by` INTEGER NULL,
    `updated_by` INTEGER NULL,

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

-- CreateTable
CREATE TABLE `db_teachers` (
    `id` INTEGER NOT NULL,
    `email` VARCHAR(255) NULL,
    `firstname` VARCHAR(255) NULL,
    `lastname` VARCHAR(255) NULL,
    `fullname` VARCHAR(255) NULL,
    `image` VARCHAR(255) NULL,
    `country_code_id` INTEGER NULL,
    `contact` VARCHAR(11) NULL,
    `gender` VARCHAR(11) NULL,
    `address_1` TEXT NULL,
    `address_2` TEXT NULL,
    `city` VARCHAR(255) NULL,
    `state` VARCHAR(255) NULL,
    `country` VARCHAR(255) NULL,
    `dob` DATETIME(3) NULL,
    `userId` INTEGER NULL,
    `schoolId` INTEGER NULL,
    `status` ENUM('ACTIVE', 'INACTIVE') NOT NULL DEFAULT 'ACTIVE',
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updated_at` DATETIME(3) NOT NULL,
    `created_by` INTEGER NULL,
    `updated_by` INTEGER NULL,

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

-- CreateTable
CREATE TABLE `db_notification` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `title` VARCHAR(255) NULL,
    `description` TEXT NULL,
    `userId` INTEGER NULL,
    `status` ENUM('ACTIVE', 'INACTIVE') NOT NULL DEFAULT 'ACTIVE',
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updated_at` DATETIME(3) NOT NULL,
    `created_by` INTEGER NULL,
    `updated_by` INTEGER NULL,

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

-- CreateTable
CREATE TABLE `db_teacher_order` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `order` TEXT NULL,
    `orderType` TEXT NULL,
    `type` VARCHAR(100) NULL,
    `courseId` INTEGER NULL,
    `moduleId` INTEGER NULL,
    `topicId` INTEGER NULL,
    `schoolCourseId` INTEGER NULL,
    `status` ENUM('ACTIVE', 'INACTIVE') NOT NULL DEFAULT 'ACTIVE',
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updated_at` DATETIME(3) NOT NULL,
    `created_by` INTEGER NULL,
    `updated_by` INTEGER NULL,

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

-- CreateTable
CREATE TABLE `db_announcement` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `title` VARCHAR(255) NOT NULL,
    `description` TEXT NULL,
    `toData` DATETIME(3) NULL,
    `fromDate` DATETIME(3) NULL,
    `courseId` INTEGER NOT NULL,
    `status` ENUM('ACTIVE', 'INACTIVE') NOT NULL DEFAULT 'ACTIVE',
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updated_at` DATETIME(3) NOT NULL,
    `created_by` INTEGER NULL,
    `updated_by` INTEGER NULL,

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

-- CreateTable
CREATE TABLE `db_learning_journey` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `journeyName` VARCHAR(255) NULL,
    `journeyGoal` VARCHAR(255) NULL,
    `duration` VARCHAR(255) NULL,
    `description` TEXT NULL,
    `courseId` INTEGER NOT NULL,
    `schoolCourseId` INTEGER NOT NULL,
    `isPublished` BOOLEAN NOT NULL DEFAULT false,
    `deleted` BOOLEAN NOT NULL DEFAULT false,
    `deletedAt` DATETIME(3) NULL,
    `deletedBy` INTEGER NULL,
    `status` ENUM('ACTIVE', 'INACTIVE') NOT NULL DEFAULT 'ACTIVE',
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updated_at` DATETIME(3) NOT NULL,
    `created_by` INTEGER NULL,
    `updated_by` INTEGER NULL,

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

-- CreateTable
CREATE TABLE `db_learning_journey_assign` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `journeyId` INTEGER NOT NULL,
    `studentId` INTEGER NOT NULL,
    `isPublished` BOOLEAN NOT NULL DEFAULT false,
    `deleted` BOOLEAN NOT NULL DEFAULT false,
    `deletedAt` DATETIME(3) NULL,
    `deletedBy` INTEGER NULL,
    `status` ENUM('ACTIVE', 'INACTIVE') NOT NULL DEFAULT 'ACTIVE',
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updated_at` DATETIME(3) NOT NULL,
    `created_by` INTEGER NULL,
    `updated_by` INTEGER NULL,

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

-- CreateTable
CREATE TABLE `db_learning_journey_sequence` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `index` INTEGER NULL DEFAULT 1,
    `point` VARCHAR(191) NULL,
    `journeyId` INTEGER NOT NULL,
    `topicId` INTEGER NULL,
    `teacherTopicId` INTEGER NULL,
    `isPublished` BOOLEAN NOT NULL DEFAULT false,
    `deleted` BOOLEAN NOT NULL DEFAULT false,
    `deletedAt` DATETIME(3) NULL,
    `deletedBy` INTEGER NULL,
    `status` ENUM('ACTIVE', 'INACTIVE') NOT NULL DEFAULT 'ACTIVE',
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updated_at` DATETIME(3) NOT NULL,
    `created_by` INTEGER NULL,
    `updated_by` INTEGER NULL,

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

-- CreateTable
CREATE TABLE `db_class_code` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `classCode` VARCHAR(191) NULL,
    `schoolCourseId` INTEGER NOT NULL,
    `schoolActivationId` INTEGER NOT NULL,
    `status` ENUM('ACTIVE', 'INACTIVE') NOT NULL DEFAULT 'ACTIVE',
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updated_at` DATETIME(3) NOT NULL,
    `created_by` INTEGER NULL,
    `updated_by` INTEGER NULL,

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

-- CreateTable
CREATE TABLE `db_class_code_map` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `schoolCourseId` INTEGER NOT NULL,
    `schoolActivationId` INTEGER NOT NULL,
    `classCodeId` INTEGER NOT NULL,
    `studentId` INTEGER NOT NULL,
    `status` ENUM('ACTIVE', 'INACTIVE') NOT NULL DEFAULT 'ACTIVE',
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updated_at` DATETIME(3) NOT NULL,
    `created_by` INTEGER NULL,
    `updated_by` INTEGER NULL,

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

-- CreateTable
CREATE TABLE `db_calender` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `title` VARCHAR(255) NULL,
    `description` TEXT NULL,
    `date` DATETIME(3) NULL,
    `toDate` DATETIME(3) NULL,
    `topicId` INTEGER NULL,
    `courseId` INTEGER NULL,
    `teacherTopicId` INTEGER NULL,
    `eventType` ENUM('LIVE_CLASS', 'ANNOUNCEMENT', 'TEACHER_SCHEDULE', 'STUDENT_SCHEDULE') NOT NULL DEFAULT 'TEACHER_SCHEDULE',
    `status` ENUM('ACTIVE', 'INACTIVE') NOT NULL DEFAULT 'ACTIVE',
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updated_at` DATETIME(3) NOT NULL,
    `created_by` INTEGER NULL,
    `updated_by` INTEGER NULL,

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

-- AddForeignKey
ALTER TABLE `db_modules` ADD CONSTRAINT `db_modules_courseId_fkey` FOREIGN KEY (`courseId`) REFERENCES `db_courses`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_topics` ADD CONSTRAINT `db_topics_moduleId_fkey` FOREIGN KEY (`moduleId`) REFERENCES `db_modules`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_activities` ADD CONSTRAINT `db_activities_topicId_fkey` FOREIGN KEY (`topicId`) REFERENCES `db_topics`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_activities` ADD CONSTRAINT `db_activities_activitesTypeId_fkey` FOREIGN KEY (`activitesTypeId`) REFERENCES `db_activities_type`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_activites_quiz` ADD CONSTRAINT `db_activites_quiz_activityId_fkey` FOREIGN KEY (`activityId`) REFERENCES `db_activities`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_activites_quiz_option` ADD CONSTRAINT `db_activites_quiz_option_quizId_fkey` FOREIGN KEY (`quizId`) REFERENCES `db_activites_quiz`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_library_topics` ADD CONSTRAINT `db_library_topics_moduleId_fkey` FOREIGN KEY (`moduleId`) REFERENCES `db_library_modules`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_library_activites` ADD CONSTRAINT `db_library_activites_topicId_fkey` FOREIGN KEY (`topicId`) REFERENCES `db_library_topics`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_library_activites` ADD CONSTRAINT `db_library_activites_activitesTypeId_fkey` FOREIGN KEY (`activitesTypeId`) REFERENCES `db_activities_type`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_library_activites_quiz` ADD CONSTRAINT `db_library_activites_quiz_activityId_fkey` FOREIGN KEY (`activityId`) REFERENCES `db_library_activites`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_library_activites_quiz_option` ADD CONSTRAINT `db_library_activites_quiz_option_quizId_fkey` FOREIGN KEY (`quizId`) REFERENCES `db_library_activites_quiz`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_teacher_modules` ADD CONSTRAINT `db_teacher_modules_courseId_fkey` FOREIGN KEY (`courseId`) REFERENCES `db_courses`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_teacher_topics` ADD CONSTRAINT `db_teacher_topics_moduleId_fkey` FOREIGN KEY (`moduleId`) REFERENCES `db_modules`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_teacher_topics` ADD CONSTRAINT `db_teacher_topics_teacherModuleId_fkey` FOREIGN KEY (`teacherModuleId`) REFERENCES `db_teacher_modules`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_teacher_activites` ADD CONSTRAINT `db_teacher_activites_topicId_fkey` FOREIGN KEY (`topicId`) REFERENCES `db_topics`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_teacher_activites` ADD CONSTRAINT `db_teacher_activites_courseId_fkey` FOREIGN KEY (`courseId`) REFERENCES `db_courses`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_teacher_activites` ADD CONSTRAINT `db_teacher_activites_teacherTopicId_fkey` FOREIGN KEY (`teacherTopicId`) REFERENCES `db_teacher_topics`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_teacher_activites` ADD CONSTRAINT `db_teacher_activites_activitesTypeId_fkey` FOREIGN KEY (`activitesTypeId`) REFERENCES `db_activities_type`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_teacher_activites_quiz` ADD CONSTRAINT `db_teacher_activites_quiz_activityId_fkey` FOREIGN KEY (`activityId`) REFERENCES `db_teacher_activites`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_teacher_activites_quiz_option` ADD CONSTRAINT `db_teacher_activites_quiz_option_quizId_fkey` FOREIGN KEY (`quizId`) REFERENCES `db_teacher_activites_quiz`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_schools` ADD CONSTRAINT `db_schools_id_fkey` FOREIGN KEY (`id`) REFERENCES `db_users`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_schools_course` ADD CONSTRAINT `db_schools_course_schoolId_fkey` FOREIGN KEY (`schoolId`) REFERENCES `db_schools`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_schools_course` ADD CONSTRAINT `db_schools_course_courseId_fkey` FOREIGN KEY (`courseId`) REFERENCES `db_courses`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_schools_course_history` ADD CONSTRAINT `db_schools_course_history_schoolId_fkey` FOREIGN KEY (`schoolId`) REFERENCES `db_schools`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_schools_course_history` ADD CONSTRAINT `db_schools_course_history_schoolCourseId_fkey` FOREIGN KEY (`schoolCourseId`) REFERENCES `db_schools_course`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_schools_course_history` ADD CONSTRAINT `db_schools_course_history_courseId_fkey` FOREIGN KEY (`courseId`) REFERENCES `db_courses`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_schools_activation_code` ADD CONSTRAINT `db_schools_activation_code_schoolId_fkey` FOREIGN KEY (`schoolId`) REFERENCES `db_schools`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_schools_activation_code` ADD CONSTRAINT `db_schools_activation_code_schoolCourseId_fkey` FOREIGN KEY (`schoolCourseId`) REFERENCES `db_schools_course`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_schools_activation_code` ADD CONSTRAINT `db_schools_activation_code_courseId_fkey` FOREIGN KEY (`courseId`) REFERENCES `db_courses`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_schools_activation_code` ADD CONSTRAINT `db_schools_activation_code_usedBy_fkey` FOREIGN KEY (`usedBy`) REFERENCES `db_users`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_students` ADD CONSTRAINT `db_students_schoolId_fkey` FOREIGN KEY (`schoolId`) REFERENCES `db_schools`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_teachers` ADD CONSTRAINT `db_teachers_schoolId_fkey` FOREIGN KEY (`schoolId`) REFERENCES `db_schools`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_notification` ADD CONSTRAINT `db_notification_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `db_users`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_teacher_order` ADD CONSTRAINT `db_teacher_order_courseId_fkey` FOREIGN KEY (`courseId`) REFERENCES `db_courses`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_teacher_order` ADD CONSTRAINT `db_teacher_order_moduleId_fkey` FOREIGN KEY (`moduleId`) REFERENCES `db_modules`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_teacher_order` ADD CONSTRAINT `db_teacher_order_topicId_fkey` FOREIGN KEY (`topicId`) REFERENCES `db_topics`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_announcement` ADD CONSTRAINT `db_announcement_courseId_fkey` FOREIGN KEY (`courseId`) REFERENCES `db_courses`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_learning_journey` ADD CONSTRAINT `db_learning_journey_courseId_fkey` FOREIGN KEY (`courseId`) REFERENCES `db_courses`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_learning_journey` ADD CONSTRAINT `db_learning_journey_schoolCourseId_fkey` FOREIGN KEY (`schoolCourseId`) REFERENCES `db_schools_course`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_learning_journey_assign` ADD CONSTRAINT `db_learning_journey_assign_journeyId_fkey` FOREIGN KEY (`journeyId`) REFERENCES `db_learning_journey`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_learning_journey_assign` ADD CONSTRAINT `db_learning_journey_assign_studentId_fkey` FOREIGN KEY (`studentId`) REFERENCES `db_students`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_learning_journey_sequence` ADD CONSTRAINT `db_learning_journey_sequence_journeyId_fkey` FOREIGN KEY (`journeyId`) REFERENCES `db_learning_journey`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_learning_journey_sequence` ADD CONSTRAINT `db_learning_journey_sequence_topicId_fkey` FOREIGN KEY (`topicId`) REFERENCES `db_topics`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_learning_journey_sequence` ADD CONSTRAINT `db_learning_journey_sequence_teacherTopicId_fkey` FOREIGN KEY (`teacherTopicId`) REFERENCES `db_teacher_topics`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_class_code` ADD CONSTRAINT `db_class_code_schoolCourseId_fkey` FOREIGN KEY (`schoolCourseId`) REFERENCES `db_schools_course`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_class_code` ADD CONSTRAINT `db_class_code_schoolActivationId_fkey` FOREIGN KEY (`schoolActivationId`) REFERENCES `db_schools_activation_code`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_class_code_map` ADD CONSTRAINT `db_class_code_map_schoolCourseId_fkey` FOREIGN KEY (`schoolCourseId`) REFERENCES `db_schools_course`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_class_code_map` ADD CONSTRAINT `db_class_code_map_schoolActivationId_fkey` FOREIGN KEY (`schoolActivationId`) REFERENCES `db_schools_activation_code`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_class_code_map` ADD CONSTRAINT `db_class_code_map_classCodeId_fkey` FOREIGN KEY (`classCodeId`) REFERENCES `db_class_code`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_class_code_map` ADD CONSTRAINT `db_class_code_map_studentId_fkey` FOREIGN KEY (`studentId`) REFERENCES `db_students`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_calender` ADD CONSTRAINT `db_calender_topicId_fkey` FOREIGN KEY (`topicId`) REFERENCES `db_topics`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_calender` ADD CONSTRAINT `db_calender_courseId_fkey` FOREIGN KEY (`courseId`) REFERENCES `db_courses`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `db_calender` ADD CONSTRAINT `db_calender_teacherTopicId_fkey` FOREIGN KEY (`teacherTopicId`) REFERENCES `db_teacher_topics`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
