数据库配置优化
This commit is contained in:
parent
ec5b2022cc
commit
6cd267985c
2
.gitignore
vendored
2
.gitignore
vendored
@ -29,7 +29,7 @@ target/
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
.AppleDouble
|
.AppleDouble
|
||||||
.LSOverride
|
.LSOverride
|
||||||
|
reading-platform-backend/prisma/migrations
|
||||||
# IDE
|
# IDE
|
||||||
.idea/
|
.idea/
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|||||||
Binary file not shown.
@ -1,262 +0,0 @@
|
|||||||
-- CreateTable
|
|
||||||
CREATE TABLE "tenants" (
|
|
||||||
"id" BIGINT NOT NULL PRIMARY KEY,
|
|
||||||
"name" TEXT NOT NULL,
|
|
||||||
"address" TEXT,
|
|
||||||
"contact_person" TEXT,
|
|
||||||
"contact_phone" TEXT,
|
|
||||||
"logo_url" TEXT,
|
|
||||||
"package_type" TEXT NOT NULL DEFAULT 'STANDARD',
|
|
||||||
"teacher_quota" INTEGER NOT NULL DEFAULT 20,
|
|
||||||
"student_quota" INTEGER NOT NULL DEFAULT 200,
|
|
||||||
"storage_quota" BIGINT NOT NULL DEFAULT 5368709120,
|
|
||||||
"start_date" TEXT NOT NULL,
|
|
||||||
"expire_date" TEXT NOT NULL,
|
|
||||||
"teacher_count" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"student_count" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"storage_used" BIGINT NOT NULL DEFAULT 0,
|
|
||||||
"status" TEXT NOT NULL DEFAULT 'ACTIVE',
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" DATETIME NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "teachers" (
|
|
||||||
"id" BIGINT NOT NULL PRIMARY KEY,
|
|
||||||
"tenant_id" BIGINT NOT NULL,
|
|
||||||
"name" TEXT NOT NULL,
|
|
||||||
"phone" TEXT NOT NULL,
|
|
||||||
"email" TEXT,
|
|
||||||
"login_account" TEXT NOT NULL,
|
|
||||||
"password_hash" TEXT NOT NULL,
|
|
||||||
"class_ids" TEXT DEFAULT '[]',
|
|
||||||
"status" TEXT NOT NULL DEFAULT 'ACTIVE',
|
|
||||||
"lesson_count" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"feedback_count" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" DATETIME NOT NULL,
|
|
||||||
"last_login_at" DATETIME,
|
|
||||||
CONSTRAINT "teachers_tenant_id_fkey" FOREIGN KEY ("tenant_id") REFERENCES "tenants" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "classes" (
|
|
||||||
"id" BIGINT NOT NULL PRIMARY KEY,
|
|
||||||
"tenant_id" BIGINT NOT NULL,
|
|
||||||
"name" TEXT NOT NULL,
|
|
||||||
"grade" TEXT NOT NULL,
|
|
||||||
"teacher_id" BIGINT,
|
|
||||||
"student_count" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"lesson_count" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" DATETIME NOT NULL,
|
|
||||||
CONSTRAINT "classes_tenant_id_fkey" FOREIGN KEY ("tenant_id") REFERENCES "tenants" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "classes_teacher_id_fkey" FOREIGN KEY ("teacher_id") REFERENCES "teachers" ("id") ON DELETE SET NULL ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "students" (
|
|
||||||
"id" BIGINT NOT NULL PRIMARY KEY,
|
|
||||||
"tenant_id" BIGINT NOT NULL,
|
|
||||||
"class_id" BIGINT NOT NULL,
|
|
||||||
"name" TEXT NOT NULL,
|
|
||||||
"gender" TEXT,
|
|
||||||
"birth_date" DATETIME,
|
|
||||||
"parent_phone" TEXT,
|
|
||||||
"parent_name" TEXT,
|
|
||||||
"reading_count" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"lesson_count" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" DATETIME NOT NULL,
|
|
||||||
CONSTRAINT "students_tenant_id_fkey" FOREIGN KEY ("tenant_id") REFERENCES "tenants" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "students_class_id_fkey" FOREIGN KEY ("class_id") REFERENCES "classes" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "courses" (
|
|
||||||
"id" BIGINT NOT NULL PRIMARY KEY,
|
|
||||||
"name" TEXT NOT NULL,
|
|
||||||
"description" TEXT,
|
|
||||||
"picture_book_id" INTEGER,
|
|
||||||
"picture_book_name" TEXT,
|
|
||||||
"grade_tags" TEXT NOT NULL DEFAULT '[]',
|
|
||||||
"domain_tags" TEXT NOT NULL DEFAULT '[]',
|
|
||||||
"duration" INTEGER NOT NULL DEFAULT 25,
|
|
||||||
"status" TEXT NOT NULL DEFAULT 'DRAFT',
|
|
||||||
"version" TEXT NOT NULL DEFAULT '1.0',
|
|
||||||
"usage_count" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"teacher_count" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"avg_rating" REAL NOT NULL DEFAULT 0,
|
|
||||||
"created_by" INTEGER,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" DATETIME NOT NULL,
|
|
||||||
"published_at" DATETIME
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "course_resources" (
|
|
||||||
"id" BIGINT NOT NULL PRIMARY KEY,
|
|
||||||
"course_id" BIGINT NOT NULL,
|
|
||||||
"resource_type" TEXT NOT NULL,
|
|
||||||
"resource_name" TEXT NOT NULL,
|
|
||||||
"file_url" TEXT NOT NULL,
|
|
||||||
"file_size" BIGINT,
|
|
||||||
"mime_type" TEXT,
|
|
||||||
"metadata" TEXT,
|
|
||||||
"sort_order" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
CONSTRAINT "course_resources_course_id_fkey" FOREIGN KEY ("course_id") REFERENCES "courses" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "course_scripts" (
|
|
||||||
"id" BIGINT NOT NULL PRIMARY KEY,
|
|
||||||
"course_id" BIGINT NOT NULL,
|
|
||||||
"step_index" INTEGER NOT NULL,
|
|
||||||
"step_name" TEXT NOT NULL,
|
|
||||||
"step_type" TEXT NOT NULL,
|
|
||||||
"duration" INTEGER NOT NULL,
|
|
||||||
"objective" TEXT,
|
|
||||||
"teacher_script" TEXT,
|
|
||||||
"interaction_points" TEXT,
|
|
||||||
"resource_ids" TEXT,
|
|
||||||
"sort_order" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" DATETIME NOT NULL,
|
|
||||||
CONSTRAINT "course_scripts_course_id_fkey" FOREIGN KEY ("course_id") REFERENCES "courses" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "course_script_pages" (
|
|
||||||
"id" BIGINT NOT NULL PRIMARY KEY,
|
|
||||||
"script_id" BIGINT NOT NULL,
|
|
||||||
"page_number" INTEGER NOT NULL,
|
|
||||||
"questions" TEXT,
|
|
||||||
"interaction_component" TEXT,
|
|
||||||
"teacher_notes" TEXT,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" DATETIME NOT NULL,
|
|
||||||
CONSTRAINT "course_script_pages_script_id_fkey" FOREIGN KEY ("script_id") REFERENCES "course_scripts" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "course_activities" (
|
|
||||||
"id" BIGINT NOT NULL PRIMARY KEY,
|
|
||||||
"course_id" BIGINT NOT NULL,
|
|
||||||
"name" TEXT NOT NULL,
|
|
||||||
"domain" TEXT,
|
|
||||||
"domain_tag_id" INTEGER,
|
|
||||||
"activity_type" TEXT NOT NULL,
|
|
||||||
"duration" INTEGER,
|
|
||||||
"online_materials" TEXT,
|
|
||||||
"offlineMaterials" TEXT,
|
|
||||||
"activityGuide" TEXT,
|
|
||||||
"objectives" TEXT,
|
|
||||||
"sort_order" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
CONSTRAINT "course_activities_course_id_fkey" FOREIGN KEY ("course_id") REFERENCES "courses" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "lessons" (
|
|
||||||
"id" BIGINT NOT NULL PRIMARY KEY,
|
|
||||||
"tenant_id" BIGINT NOT NULL,
|
|
||||||
"teacher_id" BIGINT NOT NULL,
|
|
||||||
"class_id" BIGINT NOT NULL,
|
|
||||||
"course_id" BIGINT NOT NULL,
|
|
||||||
"planned_datetime" DATETIME,
|
|
||||||
"start_datetime" DATETIME,
|
|
||||||
"end_datetime" DATETIME,
|
|
||||||
"actual_duration" INTEGER,
|
|
||||||
"status" TEXT NOT NULL DEFAULT 'PLANNED',
|
|
||||||
"overall_rating" TEXT,
|
|
||||||
"participation_rating" TEXT,
|
|
||||||
"completion_note" TEXT,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" DATETIME NOT NULL,
|
|
||||||
CONSTRAINT "lessons_tenant_id_fkey" FOREIGN KEY ("tenant_id") REFERENCES "tenants" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "lessons_teacher_id_fkey" FOREIGN KEY ("teacher_id") REFERENCES "teachers" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "lessons_class_id_fkey" FOREIGN KEY ("class_id") REFERENCES "classes" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "lessons_course_id_fkey" FOREIGN KEY ("course_id") REFERENCES "courses" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "lesson_feedbacks" (
|
|
||||||
"id" BIGINT NOT NULL PRIMARY KEY,
|
|
||||||
"lesson_id" BIGINT NOT NULL,
|
|
||||||
"teacher_id" BIGINT NOT NULL,
|
|
||||||
"design_quality" INTEGER,
|
|
||||||
"participation" INTEGER,
|
|
||||||
"goal_achievement" INTEGER,
|
|
||||||
"step_feedbacks" TEXT,
|
|
||||||
"pros" TEXT,
|
|
||||||
"suggestions" TEXT,
|
|
||||||
"activities_done" TEXT,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" DATETIME NOT NULL,
|
|
||||||
CONSTRAINT "lesson_feedbacks_lesson_id_fkey" FOREIGN KEY ("lesson_id") REFERENCES "lessons" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "lesson_feedbacks_teacher_id_fkey" FOREIGN KEY ("teacher_id") REFERENCES "teachers" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "student_records" (
|
|
||||||
"id" BIGINT NOT NULL PRIMARY KEY,
|
|
||||||
"lesson_id" BIGINT NOT NULL,
|
|
||||||
"student_id" BIGINT NOT NULL,
|
|
||||||
"focus" INTEGER,
|
|
||||||
"participation" INTEGER,
|
|
||||||
"interest" INTEGER,
|
|
||||||
"understanding" INTEGER,
|
|
||||||
"domainAchievements" TEXT,
|
|
||||||
"notes" TEXT,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" DATETIME NOT NULL,
|
|
||||||
CONSTRAINT "student_records_lesson_id_fkey" FOREIGN KEY ("lesson_id") REFERENCES "lessons" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "student_records_student_id_fkey" FOREIGN KEY ("student_id") REFERENCES "students" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "tags" (
|
|
||||||
"id" BIGINT NOT NULL PRIMARY KEY,
|
|
||||||
"level" INTEGER NOT NULL,
|
|
||||||
"code" TEXT NOT NULL,
|
|
||||||
"name" TEXT NOT NULL,
|
|
||||||
"parent_id" BIGINT,
|
|
||||||
"description" TEXT,
|
|
||||||
"metadata" TEXT,
|
|
||||||
"sort_order" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "tenant_courses" (
|
|
||||||
"id" BIGINT NOT NULL PRIMARY KEY,
|
|
||||||
"tenant_id" BIGINT NOT NULL,
|
|
||||||
"course_id" BIGINT NOT NULL,
|
|
||||||
"authorized" BOOLEAN NOT NULL DEFAULT true,
|
|
||||||
"authorized_at" DATETIME,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
CONSTRAINT "tenant_courses_tenant_id_fkey" FOREIGN KEY ("tenant_id") REFERENCES "tenants" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "tenant_courses_course_id_fkey" FOREIGN KEY ("course_id") REFERENCES "courses" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "teachers_login_account_key" ON "teachers"("login_account");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "course_scripts_course_id_step_index_key" ON "course_scripts"("course_id", "step_index");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "course_script_pages_script_id_page_number_key" ON "course_script_pages"("script_id", "page_number");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "lesson_feedbacks_lesson_id_teacher_id_key" ON "lesson_feedbacks"("lesson_id", "teacher_id");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "student_records_lesson_id_student_id_key" ON "student_records"("lesson_id", "student_id");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "tags_code_key" ON "tags"("code");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "tenant_courses_tenant_id_course_id_key" ON "tenant_courses"("tenant_id", "course_id");
|
|
||||||
@ -1,323 +0,0 @@
|
|||||||
/*
|
|
||||||
Warnings:
|
|
||||||
|
|
||||||
- The primary key for the `classes` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
|
||||||
- You are about to alter the column `id` on the `classes` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`.
|
|
||||||
- You are about to alter the column `teacher_id` on the `classes` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`.
|
|
||||||
- You are about to alter the column `tenant_id` on the `classes` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`.
|
|
||||||
- The primary key for the `course_activities` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
|
||||||
- You are about to alter the column `course_id` on the `course_activities` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`.
|
|
||||||
- You are about to alter the column `id` on the `course_activities` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`.
|
|
||||||
- The primary key for the `course_resources` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
|
||||||
- You are about to alter the column `course_id` on the `course_resources` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`.
|
|
||||||
- You are about to alter the column `file_size` on the `course_resources` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`.
|
|
||||||
- You are about to alter the column `id` on the `course_resources` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`.
|
|
||||||
- The primary key for the `course_script_pages` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
|
||||||
- You are about to alter the column `id` on the `course_script_pages` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`.
|
|
||||||
- You are about to alter the column `script_id` on the `course_script_pages` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`.
|
|
||||||
- The primary key for the `course_scripts` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
|
||||||
- You are about to alter the column `course_id` on the `course_scripts` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`.
|
|
||||||
- You are about to alter the column `id` on the `course_scripts` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`.
|
|
||||||
- The primary key for the `courses` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
|
||||||
- You are about to alter the column `id` on the `courses` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`.
|
|
||||||
- The primary key for the `lesson_feedbacks` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
|
||||||
- You are about to alter the column `id` on the `lesson_feedbacks` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`.
|
|
||||||
- You are about to alter the column `lesson_id` on the `lesson_feedbacks` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`.
|
|
||||||
- You are about to alter the column `teacher_id` on the `lesson_feedbacks` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`.
|
|
||||||
- The primary key for the `lessons` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
|
||||||
- You are about to alter the column `class_id` on the `lessons` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`.
|
|
||||||
- You are about to alter the column `course_id` on the `lessons` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`.
|
|
||||||
- You are about to alter the column `id` on the `lessons` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`.
|
|
||||||
- You are about to alter the column `teacher_id` on the `lessons` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`.
|
|
||||||
- You are about to alter the column `tenant_id` on the `lessons` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`.
|
|
||||||
- The primary key for the `student_records` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
|
||||||
- You are about to alter the column `id` on the `student_records` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`.
|
|
||||||
- You are about to alter the column `lesson_id` on the `student_records` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`.
|
|
||||||
- You are about to alter the column `student_id` on the `student_records` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`.
|
|
||||||
- The primary key for the `students` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
|
||||||
- You are about to alter the column `class_id` on the `students` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`.
|
|
||||||
- You are about to alter the column `id` on the `students` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`.
|
|
||||||
- You are about to alter the column `tenant_id` on the `students` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`.
|
|
||||||
- The primary key for the `tags` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
|
||||||
- You are about to alter the column `id` on the `tags` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`.
|
|
||||||
- You are about to alter the column `parent_id` on the `tags` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`.
|
|
||||||
- The primary key for the `teachers` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
|
||||||
- You are about to alter the column `id` on the `teachers` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`.
|
|
||||||
- You are about to alter the column `tenant_id` on the `teachers` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`.
|
|
||||||
- The primary key for the `tenant_courses` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
|
||||||
- You are about to alter the column `course_id` on the `tenant_courses` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`.
|
|
||||||
- You are about to alter the column `id` on the `tenant_courses` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`.
|
|
||||||
- You are about to alter the column `tenant_id` on the `tenant_courses` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`.
|
|
||||||
- The primary key for the `tenants` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
|
||||||
- You are about to alter the column `id` on the `tenants` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`.
|
|
||||||
- Made the column `picture_book_id` on table `courses` required. This step will fail if there are existing NULL values in that column.
|
|
||||||
|
|
||||||
*/
|
|
||||||
-- RedefineTables
|
|
||||||
PRAGMA defer_foreign_keys=ON;
|
|
||||||
PRAGMA foreign_keys=OFF;
|
|
||||||
CREATE TABLE "new_classes" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"tenant_id" INTEGER NOT NULL,
|
|
||||||
"name" TEXT NOT NULL,
|
|
||||||
"grade" TEXT NOT NULL,
|
|
||||||
"teacher_id" INTEGER,
|
|
||||||
"student_count" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"lesson_count" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" DATETIME NOT NULL,
|
|
||||||
CONSTRAINT "classes_tenant_id_fkey" FOREIGN KEY ("tenant_id") REFERENCES "tenants" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "classes_teacher_id_fkey" FOREIGN KEY ("teacher_id") REFERENCES "teachers" ("id") ON DELETE SET NULL ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
INSERT INTO "new_classes" ("created_at", "grade", "id", "lesson_count", "name", "student_count", "teacher_id", "tenant_id", "updated_at") SELECT "created_at", "grade", "id", "lesson_count", "name", "student_count", "teacher_id", "tenant_id", "updated_at" FROM "classes";
|
|
||||||
DROP TABLE "classes";
|
|
||||||
ALTER TABLE "new_classes" RENAME TO "classes";
|
|
||||||
CREATE TABLE "new_course_activities" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"course_id" INTEGER NOT NULL,
|
|
||||||
"name" TEXT NOT NULL,
|
|
||||||
"domain" TEXT,
|
|
||||||
"domain_tag_id" INTEGER,
|
|
||||||
"activity_type" TEXT NOT NULL,
|
|
||||||
"duration" INTEGER,
|
|
||||||
"online_materials" TEXT,
|
|
||||||
"offlineMaterials" TEXT,
|
|
||||||
"activityGuide" TEXT,
|
|
||||||
"objectives" TEXT,
|
|
||||||
"sort_order" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
CONSTRAINT "course_activities_course_id_fkey" FOREIGN KEY ("course_id") REFERENCES "courses" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
INSERT INTO "new_course_activities" ("activityGuide", "activity_type", "course_id", "created_at", "domain", "domain_tag_id", "duration", "id", "name", "objectives", "offlineMaterials", "online_materials", "sort_order") SELECT "activityGuide", "activity_type", "course_id", "created_at", "domain", "domain_tag_id", "duration", "id", "name", "objectives", "offlineMaterials", "online_materials", "sort_order" FROM "course_activities";
|
|
||||||
DROP TABLE "course_activities";
|
|
||||||
ALTER TABLE "new_course_activities" RENAME TO "course_activities";
|
|
||||||
CREATE TABLE "new_course_resources" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"course_id" INTEGER NOT NULL,
|
|
||||||
"resource_type" TEXT NOT NULL,
|
|
||||||
"resource_name" TEXT NOT NULL,
|
|
||||||
"file_url" TEXT NOT NULL,
|
|
||||||
"file_size" INTEGER,
|
|
||||||
"mime_type" TEXT,
|
|
||||||
"metadata" TEXT,
|
|
||||||
"sort_order" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
CONSTRAINT "course_resources_course_id_fkey" FOREIGN KEY ("course_id") REFERENCES "courses" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
INSERT INTO "new_course_resources" ("course_id", "created_at", "file_size", "file_url", "id", "metadata", "mime_type", "resource_name", "resource_type", "sort_order") SELECT "course_id", "created_at", "file_size", "file_url", "id", "metadata", "mime_type", "resource_name", "resource_type", "sort_order" FROM "course_resources";
|
|
||||||
DROP TABLE "course_resources";
|
|
||||||
ALTER TABLE "new_course_resources" RENAME TO "course_resources";
|
|
||||||
CREATE TABLE "new_course_script_pages" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"script_id" INTEGER NOT NULL,
|
|
||||||
"page_number" INTEGER NOT NULL,
|
|
||||||
"questions" TEXT,
|
|
||||||
"interaction_component" TEXT,
|
|
||||||
"teacher_notes" TEXT,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" DATETIME NOT NULL,
|
|
||||||
CONSTRAINT "course_script_pages_script_id_fkey" FOREIGN KEY ("script_id") REFERENCES "course_scripts" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
INSERT INTO "new_course_script_pages" ("created_at", "id", "interaction_component", "page_number", "questions", "script_id", "teacher_notes", "updated_at") SELECT "created_at", "id", "interaction_component", "page_number", "questions", "script_id", "teacher_notes", "updated_at" FROM "course_script_pages";
|
|
||||||
DROP TABLE "course_script_pages";
|
|
||||||
ALTER TABLE "new_course_script_pages" RENAME TO "course_script_pages";
|
|
||||||
CREATE UNIQUE INDEX "course_script_pages_script_id_page_number_key" ON "course_script_pages"("script_id", "page_number");
|
|
||||||
CREATE TABLE "new_course_scripts" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"course_id" INTEGER NOT NULL,
|
|
||||||
"step_index" INTEGER NOT NULL,
|
|
||||||
"step_name" TEXT NOT NULL,
|
|
||||||
"step_type" TEXT NOT NULL,
|
|
||||||
"duration" INTEGER NOT NULL,
|
|
||||||
"objective" TEXT,
|
|
||||||
"teacher_script" TEXT,
|
|
||||||
"interaction_points" TEXT,
|
|
||||||
"resource_ids" TEXT,
|
|
||||||
"sort_order" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" DATETIME NOT NULL,
|
|
||||||
CONSTRAINT "course_scripts_course_id_fkey" FOREIGN KEY ("course_id") REFERENCES "courses" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
INSERT INTO "new_course_scripts" ("course_id", "created_at", "duration", "id", "interaction_points", "objective", "resource_ids", "sort_order", "step_index", "step_name", "step_type", "teacher_script", "updated_at") SELECT "course_id", "created_at", "duration", "id", "interaction_points", "objective", "resource_ids", "sort_order", "step_index", "step_name", "step_type", "teacher_script", "updated_at" FROM "course_scripts";
|
|
||||||
DROP TABLE "course_scripts";
|
|
||||||
ALTER TABLE "new_course_scripts" RENAME TO "course_scripts";
|
|
||||||
CREATE UNIQUE INDEX "course_scripts_course_id_step_index_key" ON "course_scripts"("course_id", "step_index");
|
|
||||||
CREATE TABLE "new_courses" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"name" TEXT NOT NULL,
|
|
||||||
"description" TEXT,
|
|
||||||
"picture_book_id" INTEGER NOT NULL,
|
|
||||||
"picture_book_name" TEXT,
|
|
||||||
"grade_tags" TEXT NOT NULL DEFAULT '[]',
|
|
||||||
"domain_tags" TEXT NOT NULL DEFAULT '[]',
|
|
||||||
"duration" INTEGER NOT NULL DEFAULT 25,
|
|
||||||
"status" TEXT NOT NULL DEFAULT 'DRAFT',
|
|
||||||
"version" TEXT NOT NULL DEFAULT '1.0',
|
|
||||||
"usage_count" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"teacher_count" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"avg_rating" REAL NOT NULL DEFAULT 0,
|
|
||||||
"created_by" INTEGER,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" DATETIME NOT NULL,
|
|
||||||
"published_at" DATETIME
|
|
||||||
);
|
|
||||||
INSERT INTO "new_courses" ("avg_rating", "created_at", "created_by", "description", "domain_tags", "duration", "grade_tags", "id", "name", "picture_book_id", "picture_book_name", "published_at", "status", "teacher_count", "updated_at", "usage_count", "version") SELECT "avg_rating", "created_at", "created_by", "description", "domain_tags", "duration", "grade_tags", "id", "name", "picture_book_id", "picture_book_name", "published_at", "status", "teacher_count", "updated_at", "usage_count", "version" FROM "courses";
|
|
||||||
DROP TABLE "courses";
|
|
||||||
ALTER TABLE "new_courses" RENAME TO "courses";
|
|
||||||
CREATE TABLE "new_lesson_feedbacks" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"lesson_id" INTEGER NOT NULL,
|
|
||||||
"teacher_id" INTEGER NOT NULL,
|
|
||||||
"design_quality" INTEGER,
|
|
||||||
"participation" INTEGER,
|
|
||||||
"goal_achievement" INTEGER,
|
|
||||||
"step_feedbacks" TEXT,
|
|
||||||
"pros" TEXT,
|
|
||||||
"suggestions" TEXT,
|
|
||||||
"activities_done" TEXT,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" DATETIME NOT NULL,
|
|
||||||
CONSTRAINT "lesson_feedbacks_lesson_id_fkey" FOREIGN KEY ("lesson_id") REFERENCES "lessons" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "lesson_feedbacks_teacher_id_fkey" FOREIGN KEY ("teacher_id") REFERENCES "teachers" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
INSERT INTO "new_lesson_feedbacks" ("activities_done", "created_at", "design_quality", "goal_achievement", "id", "lesson_id", "participation", "pros", "step_feedbacks", "suggestions", "teacher_id", "updated_at") SELECT "activities_done", "created_at", "design_quality", "goal_achievement", "id", "lesson_id", "participation", "pros", "step_feedbacks", "suggestions", "teacher_id", "updated_at" FROM "lesson_feedbacks";
|
|
||||||
DROP TABLE "lesson_feedbacks";
|
|
||||||
ALTER TABLE "new_lesson_feedbacks" RENAME TO "lesson_feedbacks";
|
|
||||||
CREATE UNIQUE INDEX "lesson_feedbacks_lesson_id_teacher_id_key" ON "lesson_feedbacks"("lesson_id", "teacher_id");
|
|
||||||
CREATE TABLE "new_lessons" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"tenant_id" INTEGER NOT NULL,
|
|
||||||
"teacher_id" INTEGER NOT NULL,
|
|
||||||
"class_id" INTEGER NOT NULL,
|
|
||||||
"course_id" INTEGER NOT NULL,
|
|
||||||
"planned_datetime" DATETIME,
|
|
||||||
"start_datetime" DATETIME,
|
|
||||||
"end_datetime" DATETIME,
|
|
||||||
"actual_duration" INTEGER,
|
|
||||||
"status" TEXT NOT NULL DEFAULT 'PLANNED',
|
|
||||||
"overall_rating" TEXT,
|
|
||||||
"participation_rating" TEXT,
|
|
||||||
"completion_note" TEXT,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" DATETIME NOT NULL,
|
|
||||||
CONSTRAINT "lessons_tenant_id_fkey" FOREIGN KEY ("tenant_id") REFERENCES "tenants" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "lessons_teacher_id_fkey" FOREIGN KEY ("teacher_id") REFERENCES "teachers" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "lessons_class_id_fkey" FOREIGN KEY ("class_id") REFERENCES "classes" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "lessons_course_id_fkey" FOREIGN KEY ("course_id") REFERENCES "courses" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
INSERT INTO "new_lessons" ("actual_duration", "class_id", "completion_note", "course_id", "created_at", "end_datetime", "id", "overall_rating", "participation_rating", "planned_datetime", "start_datetime", "status", "teacher_id", "tenant_id", "updated_at") SELECT "actual_duration", "class_id", "completion_note", "course_id", "created_at", "end_datetime", "id", "overall_rating", "participation_rating", "planned_datetime", "start_datetime", "status", "teacher_id", "tenant_id", "updated_at" FROM "lessons";
|
|
||||||
DROP TABLE "lessons";
|
|
||||||
ALTER TABLE "new_lessons" RENAME TO "lessons";
|
|
||||||
CREATE TABLE "new_student_records" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"lesson_id" INTEGER NOT NULL,
|
|
||||||
"student_id" INTEGER NOT NULL,
|
|
||||||
"focus" INTEGER,
|
|
||||||
"participation" INTEGER,
|
|
||||||
"interest" INTEGER,
|
|
||||||
"understanding" INTEGER,
|
|
||||||
"domainAchievements" TEXT,
|
|
||||||
"notes" TEXT,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" DATETIME NOT NULL,
|
|
||||||
CONSTRAINT "student_records_lesson_id_fkey" FOREIGN KEY ("lesson_id") REFERENCES "lessons" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "student_records_student_id_fkey" FOREIGN KEY ("student_id") REFERENCES "students" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
INSERT INTO "new_student_records" ("created_at", "domainAchievements", "focus", "id", "interest", "lesson_id", "notes", "participation", "student_id", "understanding", "updated_at") SELECT "created_at", "domainAchievements", "focus", "id", "interest", "lesson_id", "notes", "participation", "student_id", "understanding", "updated_at" FROM "student_records";
|
|
||||||
DROP TABLE "student_records";
|
|
||||||
ALTER TABLE "new_student_records" RENAME TO "student_records";
|
|
||||||
CREATE UNIQUE INDEX "student_records_lesson_id_student_id_key" ON "student_records"("lesson_id", "student_id");
|
|
||||||
CREATE TABLE "new_students" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"tenant_id" INTEGER NOT NULL,
|
|
||||||
"class_id" INTEGER NOT NULL,
|
|
||||||
"name" TEXT NOT NULL,
|
|
||||||
"gender" TEXT,
|
|
||||||
"birth_date" DATETIME,
|
|
||||||
"parent_phone" TEXT,
|
|
||||||
"parent_name" TEXT,
|
|
||||||
"reading_count" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"lesson_count" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" DATETIME NOT NULL,
|
|
||||||
CONSTRAINT "students_tenant_id_fkey" FOREIGN KEY ("tenant_id") REFERENCES "tenants" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "students_class_id_fkey" FOREIGN KEY ("class_id") REFERENCES "classes" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
INSERT INTO "new_students" ("birth_date", "class_id", "created_at", "gender", "id", "lesson_count", "name", "parent_name", "parent_phone", "reading_count", "tenant_id", "updated_at") SELECT "birth_date", "class_id", "created_at", "gender", "id", "lesson_count", "name", "parent_name", "parent_phone", "reading_count", "tenant_id", "updated_at" FROM "students";
|
|
||||||
DROP TABLE "students";
|
|
||||||
ALTER TABLE "new_students" RENAME TO "students";
|
|
||||||
CREATE TABLE "new_tags" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"level" INTEGER NOT NULL,
|
|
||||||
"code" TEXT NOT NULL,
|
|
||||||
"name" TEXT NOT NULL,
|
|
||||||
"parent_id" INTEGER,
|
|
||||||
"description" TEXT,
|
|
||||||
"metadata" TEXT,
|
|
||||||
"sort_order" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
||||||
);
|
|
||||||
INSERT INTO "new_tags" ("code", "created_at", "description", "id", "level", "metadata", "name", "parent_id", "sort_order") SELECT "code", "created_at", "description", "id", "level", "metadata", "name", "parent_id", "sort_order" FROM "tags";
|
|
||||||
DROP TABLE "tags";
|
|
||||||
ALTER TABLE "new_tags" RENAME TO "tags";
|
|
||||||
CREATE UNIQUE INDEX "tags_code_key" ON "tags"("code");
|
|
||||||
CREATE TABLE "new_teachers" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"tenant_id" INTEGER NOT NULL,
|
|
||||||
"name" TEXT NOT NULL,
|
|
||||||
"phone" TEXT NOT NULL,
|
|
||||||
"email" TEXT,
|
|
||||||
"login_account" TEXT NOT NULL,
|
|
||||||
"password_hash" TEXT NOT NULL,
|
|
||||||
"class_ids" TEXT DEFAULT '[]',
|
|
||||||
"status" TEXT NOT NULL DEFAULT 'ACTIVE',
|
|
||||||
"lesson_count" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"feedback_count" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" DATETIME NOT NULL,
|
|
||||||
"last_login_at" DATETIME,
|
|
||||||
CONSTRAINT "teachers_tenant_id_fkey" FOREIGN KEY ("tenant_id") REFERENCES "tenants" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
INSERT INTO "new_teachers" ("class_ids", "created_at", "email", "feedback_count", "id", "last_login_at", "lesson_count", "login_account", "name", "password_hash", "phone", "status", "tenant_id", "updated_at") SELECT "class_ids", "created_at", "email", "feedback_count", "id", "last_login_at", "lesson_count", "login_account", "name", "password_hash", "phone", "status", "tenant_id", "updated_at" FROM "teachers";
|
|
||||||
DROP TABLE "teachers";
|
|
||||||
ALTER TABLE "new_teachers" RENAME TO "teachers";
|
|
||||||
CREATE UNIQUE INDEX "teachers_login_account_key" ON "teachers"("login_account");
|
|
||||||
CREATE TABLE "new_tenant_courses" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"tenant_id" INTEGER NOT NULL,
|
|
||||||
"course_id" INTEGER NOT NULL,
|
|
||||||
"authorized" BOOLEAN NOT NULL DEFAULT true,
|
|
||||||
"authorized_at" DATETIME,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
CONSTRAINT "tenant_courses_tenant_id_fkey" FOREIGN KEY ("tenant_id") REFERENCES "tenants" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "tenant_courses_course_id_fkey" FOREIGN KEY ("course_id") REFERENCES "courses" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
INSERT INTO "new_tenant_courses" ("authorized", "authorized_at", "course_id", "created_at", "id", "tenant_id") SELECT "authorized", "authorized_at", "course_id", "created_at", "id", "tenant_id" FROM "tenant_courses";
|
|
||||||
DROP TABLE "tenant_courses";
|
|
||||||
ALTER TABLE "new_tenant_courses" RENAME TO "tenant_courses";
|
|
||||||
CREATE UNIQUE INDEX "tenant_courses_tenant_id_course_id_key" ON "tenant_courses"("tenant_id", "course_id");
|
|
||||||
CREATE TABLE "new_tenants" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"name" TEXT NOT NULL,
|
|
||||||
"address" TEXT,
|
|
||||||
"contact_person" TEXT,
|
|
||||||
"contact_phone" TEXT,
|
|
||||||
"logo_url" TEXT,
|
|
||||||
"package_type" TEXT NOT NULL DEFAULT 'STANDARD',
|
|
||||||
"teacher_quota" INTEGER NOT NULL DEFAULT 20,
|
|
||||||
"student_quota" INTEGER NOT NULL DEFAULT 200,
|
|
||||||
"storage_quota" BIGINT NOT NULL DEFAULT 5368709120,
|
|
||||||
"start_date" TEXT NOT NULL,
|
|
||||||
"expire_date" TEXT NOT NULL,
|
|
||||||
"teacher_count" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"student_count" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"storage_used" BIGINT NOT NULL DEFAULT 0,
|
|
||||||
"status" TEXT NOT NULL DEFAULT 'ACTIVE',
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" DATETIME NOT NULL
|
|
||||||
);
|
|
||||||
INSERT INTO "new_tenants" ("address", "contact_person", "contact_phone", "created_at", "expire_date", "id", "logo_url", "name", "package_type", "start_date", "status", "storage_quota", "storage_used", "student_count", "student_quota", "teacher_count", "teacher_quota", "updated_at") SELECT "address", "contact_person", "contact_phone", "created_at", "expire_date", "id", "logo_url", "name", "package_type", "start_date", "status", "storage_quota", "storage_used", "student_count", "student_quota", "teacher_count", "teacher_quota", "updated_at" FROM "tenants";
|
|
||||||
DROP TABLE "tenants";
|
|
||||||
ALTER TABLE "new_tenants" RENAME TO "tenants";
|
|
||||||
PRAGMA foreign_keys=ON;
|
|
||||||
PRAGMA defer_foreign_keys=OFF;
|
|
||||||
@ -1,27 +0,0 @@
|
|||||||
-- RedefineTables
|
|
||||||
PRAGMA defer_foreign_keys=ON;
|
|
||||||
PRAGMA foreign_keys=OFF;
|
|
||||||
CREATE TABLE "new_courses" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"name" TEXT NOT NULL,
|
|
||||||
"description" TEXT,
|
|
||||||
"picture_book_id" INTEGER,
|
|
||||||
"picture_book_name" TEXT,
|
|
||||||
"grade_tags" TEXT NOT NULL DEFAULT '[]',
|
|
||||||
"domain_tags" TEXT NOT NULL DEFAULT '[]',
|
|
||||||
"duration" INTEGER NOT NULL DEFAULT 25,
|
|
||||||
"status" TEXT NOT NULL DEFAULT 'DRAFT',
|
|
||||||
"version" TEXT NOT NULL DEFAULT '1.0',
|
|
||||||
"usage_count" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"teacher_count" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"avg_rating" REAL NOT NULL DEFAULT 0,
|
|
||||||
"created_by" INTEGER,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" DATETIME NOT NULL,
|
|
||||||
"published_at" DATETIME
|
|
||||||
);
|
|
||||||
INSERT INTO "new_courses" ("avg_rating", "created_at", "created_by", "description", "domain_tags", "duration", "grade_tags", "id", "name", "picture_book_id", "picture_book_name", "published_at", "status", "teacher_count", "updated_at", "usage_count", "version") SELECT "avg_rating", "created_at", "created_by", "description", "domain_tags", "duration", "grade_tags", "id", "name", "picture_book_id", "picture_book_name", "published_at", "status", "teacher_count", "updated_at", "usage_count", "version" FROM "courses";
|
|
||||||
DROP TABLE "courses";
|
|
||||||
ALTER TABLE "new_courses" RENAME TO "courses";
|
|
||||||
PRAGMA foreign_keys=ON;
|
|
||||||
PRAGMA defer_foreign_keys=OFF;
|
|
||||||
@ -1,634 +0,0 @@
|
|||||||
-- CreateTable
|
|
||||||
CREATE TABLE "tenants" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"name" TEXT NOT NULL,
|
|
||||||
"login_account" TEXT,
|
|
||||||
"password_hash" TEXT,
|
|
||||||
"address" TEXT,
|
|
||||||
"contact_person" TEXT,
|
|
||||||
"contact_phone" TEXT,
|
|
||||||
"logo_url" TEXT,
|
|
||||||
"package_type" TEXT NOT NULL DEFAULT 'STANDARD',
|
|
||||||
"teacher_quota" INTEGER NOT NULL DEFAULT 20,
|
|
||||||
"student_quota" INTEGER NOT NULL DEFAULT 200,
|
|
||||||
"storage_quota" BIGINT NOT NULL DEFAULT 5368709120,
|
|
||||||
"start_date" TEXT NOT NULL,
|
|
||||||
"expire_date" TEXT NOT NULL,
|
|
||||||
"teacher_count" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"student_count" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"storage_used" BIGINT NOT NULL DEFAULT 0,
|
|
||||||
"status" TEXT NOT NULL DEFAULT 'ACTIVE',
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" DATETIME NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "teachers" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"tenant_id" INTEGER NOT NULL,
|
|
||||||
"name" TEXT NOT NULL,
|
|
||||||
"phone" TEXT NOT NULL,
|
|
||||||
"email" TEXT,
|
|
||||||
"login_account" TEXT NOT NULL,
|
|
||||||
"password_hash" TEXT NOT NULL,
|
|
||||||
"class_ids" TEXT DEFAULT '[]',
|
|
||||||
"status" TEXT NOT NULL DEFAULT 'ACTIVE',
|
|
||||||
"lesson_count" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"feedback_count" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" DATETIME NOT NULL,
|
|
||||||
"last_login_at" DATETIME,
|
|
||||||
CONSTRAINT "teachers_tenant_id_fkey" FOREIGN KEY ("tenant_id") REFERENCES "tenants" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "classes" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"tenant_id" INTEGER NOT NULL,
|
|
||||||
"name" TEXT NOT NULL,
|
|
||||||
"grade" TEXT NOT NULL,
|
|
||||||
"teacher_id" INTEGER,
|
|
||||||
"student_count" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"lesson_count" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" DATETIME NOT NULL,
|
|
||||||
CONSTRAINT "classes_tenant_id_fkey" FOREIGN KEY ("tenant_id") REFERENCES "tenants" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "classes_teacher_id_fkey" FOREIGN KEY ("teacher_id") REFERENCES "teachers" ("id") ON DELETE SET NULL ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "students" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"tenant_id" INTEGER NOT NULL,
|
|
||||||
"class_id" INTEGER NOT NULL,
|
|
||||||
"name" TEXT NOT NULL,
|
|
||||||
"gender" TEXT,
|
|
||||||
"birth_date" DATETIME,
|
|
||||||
"parent_phone" TEXT,
|
|
||||||
"parent_name" TEXT,
|
|
||||||
"reading_count" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"lesson_count" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" DATETIME NOT NULL,
|
|
||||||
CONSTRAINT "students_tenant_id_fkey" FOREIGN KEY ("tenant_id") REFERENCES "tenants" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "students_class_id_fkey" FOREIGN KEY ("class_id") REFERENCES "classes" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "courses" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"name" TEXT NOT NULL,
|
|
||||||
"description" TEXT,
|
|
||||||
"picture_book_id" INTEGER,
|
|
||||||
"picture_book_name" TEXT,
|
|
||||||
"cover_image_path" TEXT,
|
|
||||||
"ebook_paths" TEXT,
|
|
||||||
"audio_paths" TEXT,
|
|
||||||
"video_paths" TEXT,
|
|
||||||
"other_resources" TEXT,
|
|
||||||
"ppt_path" TEXT,
|
|
||||||
"ppt_name" TEXT,
|
|
||||||
"poster_paths" TEXT,
|
|
||||||
"tools" TEXT,
|
|
||||||
"student_materials" TEXT,
|
|
||||||
"lesson_plan_data" TEXT,
|
|
||||||
"activities_data" TEXT,
|
|
||||||
"assessment_data" TEXT,
|
|
||||||
"grade_tags" TEXT NOT NULL DEFAULT '[]',
|
|
||||||
"domain_tags" TEXT NOT NULL DEFAULT '[]',
|
|
||||||
"duration" INTEGER NOT NULL DEFAULT 25,
|
|
||||||
"status" TEXT NOT NULL DEFAULT 'DRAFT',
|
|
||||||
"version" TEXT NOT NULL DEFAULT '1.0',
|
|
||||||
"submitted_at" DATETIME,
|
|
||||||
"submitted_by" INTEGER,
|
|
||||||
"reviewed_at" DATETIME,
|
|
||||||
"reviewed_by" INTEGER,
|
|
||||||
"review_comment" TEXT,
|
|
||||||
"review_checklist" TEXT,
|
|
||||||
"parent_id" INTEGER,
|
|
||||||
"isLatest" BOOLEAN NOT NULL DEFAULT true,
|
|
||||||
"usage_count" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"teacher_count" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"avg_rating" REAL NOT NULL DEFAULT 0,
|
|
||||||
"created_by" INTEGER,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" DATETIME NOT NULL,
|
|
||||||
"published_at" DATETIME
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "course_versions" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"course_id" INTEGER NOT NULL,
|
|
||||||
"version" TEXT NOT NULL,
|
|
||||||
"snapshotData" TEXT NOT NULL,
|
|
||||||
"changeLog" TEXT,
|
|
||||||
"published_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"published_by" INTEGER NOT NULL,
|
|
||||||
CONSTRAINT "course_versions_course_id_fkey" FOREIGN KEY ("course_id") REFERENCES "courses" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "course_resources" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"course_id" INTEGER NOT NULL,
|
|
||||||
"resource_type" TEXT NOT NULL,
|
|
||||||
"resource_name" TEXT NOT NULL,
|
|
||||||
"file_url" TEXT NOT NULL,
|
|
||||||
"file_size" INTEGER,
|
|
||||||
"mime_type" TEXT,
|
|
||||||
"metadata" TEXT,
|
|
||||||
"sort_order" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
CONSTRAINT "course_resources_course_id_fkey" FOREIGN KEY ("course_id") REFERENCES "courses" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "course_scripts" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"course_id" INTEGER NOT NULL,
|
|
||||||
"step_index" INTEGER NOT NULL,
|
|
||||||
"step_name" TEXT NOT NULL,
|
|
||||||
"step_type" TEXT NOT NULL,
|
|
||||||
"duration" INTEGER NOT NULL,
|
|
||||||
"objective" TEXT,
|
|
||||||
"teacher_script" TEXT,
|
|
||||||
"interaction_points" TEXT,
|
|
||||||
"resource_ids" TEXT,
|
|
||||||
"sort_order" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" DATETIME NOT NULL,
|
|
||||||
CONSTRAINT "course_scripts_course_id_fkey" FOREIGN KEY ("course_id") REFERENCES "courses" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "course_script_pages" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"script_id" INTEGER NOT NULL,
|
|
||||||
"page_number" INTEGER NOT NULL,
|
|
||||||
"questions" TEXT,
|
|
||||||
"interaction_component" TEXT,
|
|
||||||
"teacher_notes" TEXT,
|
|
||||||
"resource_ids" TEXT,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" DATETIME NOT NULL,
|
|
||||||
CONSTRAINT "course_script_pages_script_id_fkey" FOREIGN KEY ("script_id") REFERENCES "course_scripts" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "course_activities" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"course_id" INTEGER NOT NULL,
|
|
||||||
"name" TEXT NOT NULL,
|
|
||||||
"domain" TEXT,
|
|
||||||
"domain_tag_id" INTEGER,
|
|
||||||
"activity_type" TEXT NOT NULL,
|
|
||||||
"duration" INTEGER,
|
|
||||||
"online_materials" TEXT,
|
|
||||||
"offlineMaterials" TEXT,
|
|
||||||
"activityGuide" TEXT,
|
|
||||||
"objectives" TEXT,
|
|
||||||
"sort_order" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
CONSTRAINT "course_activities_course_id_fkey" FOREIGN KEY ("course_id") REFERENCES "courses" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "lessons" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"tenant_id" INTEGER NOT NULL,
|
|
||||||
"teacher_id" INTEGER NOT NULL,
|
|
||||||
"class_id" INTEGER NOT NULL,
|
|
||||||
"course_id" INTEGER NOT NULL,
|
|
||||||
"schedule_plan_id" INTEGER,
|
|
||||||
"planned_datetime" DATETIME,
|
|
||||||
"start_datetime" DATETIME,
|
|
||||||
"end_datetime" DATETIME,
|
|
||||||
"actual_duration" INTEGER,
|
|
||||||
"status" TEXT NOT NULL DEFAULT 'PLANNED',
|
|
||||||
"overall_rating" TEXT,
|
|
||||||
"participation_rating" TEXT,
|
|
||||||
"completion_note" TEXT,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" DATETIME NOT NULL,
|
|
||||||
CONSTRAINT "lessons_tenant_id_fkey" FOREIGN KEY ("tenant_id") REFERENCES "tenants" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "lessons_teacher_id_fkey" FOREIGN KEY ("teacher_id") REFERENCES "teachers" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "lessons_class_id_fkey" FOREIGN KEY ("class_id") REFERENCES "classes" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "lessons_course_id_fkey" FOREIGN KEY ("course_id") REFERENCES "courses" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "lessons_schedule_plan_id_fkey" FOREIGN KEY ("schedule_plan_id") REFERENCES "schedule_plans" ("id") ON DELETE SET NULL ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "lesson_feedbacks" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"lesson_id" INTEGER NOT NULL,
|
|
||||||
"teacher_id" INTEGER NOT NULL,
|
|
||||||
"design_quality" INTEGER,
|
|
||||||
"participation" INTEGER,
|
|
||||||
"goal_achievement" INTEGER,
|
|
||||||
"step_feedbacks" TEXT,
|
|
||||||
"pros" TEXT,
|
|
||||||
"suggestions" TEXT,
|
|
||||||
"activities_done" TEXT,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" DATETIME NOT NULL,
|
|
||||||
CONSTRAINT "lesson_feedbacks_lesson_id_fkey" FOREIGN KEY ("lesson_id") REFERENCES "lessons" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "lesson_feedbacks_teacher_id_fkey" FOREIGN KEY ("teacher_id") REFERENCES "teachers" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "student_records" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"lesson_id" INTEGER NOT NULL,
|
|
||||||
"student_id" INTEGER NOT NULL,
|
|
||||||
"focus" INTEGER,
|
|
||||||
"participation" INTEGER,
|
|
||||||
"interest" INTEGER,
|
|
||||||
"understanding" INTEGER,
|
|
||||||
"domainAchievements" TEXT,
|
|
||||||
"notes" TEXT,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" DATETIME NOT NULL,
|
|
||||||
CONSTRAINT "student_records_lesson_id_fkey" FOREIGN KEY ("lesson_id") REFERENCES "lessons" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "student_records_student_id_fkey" FOREIGN KEY ("student_id") REFERENCES "students" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "tags" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"level" INTEGER NOT NULL,
|
|
||||||
"code" TEXT NOT NULL,
|
|
||||||
"name" TEXT NOT NULL,
|
|
||||||
"parent_id" INTEGER,
|
|
||||||
"description" TEXT,
|
|
||||||
"metadata" TEXT,
|
|
||||||
"sort_order" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "tenant_courses" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"tenant_id" INTEGER NOT NULL,
|
|
||||||
"course_id" INTEGER NOT NULL,
|
|
||||||
"authorized" BOOLEAN NOT NULL DEFAULT true,
|
|
||||||
"authorized_at" DATETIME,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
CONSTRAINT "tenant_courses_tenant_id_fkey" FOREIGN KEY ("tenant_id") REFERENCES "tenants" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "tenant_courses_course_id_fkey" FOREIGN KEY ("course_id") REFERENCES "courses" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "growth_records" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"tenant_id" INTEGER NOT NULL,
|
|
||||||
"student_id" INTEGER NOT NULL,
|
|
||||||
"class_id" INTEGER,
|
|
||||||
"record_type" TEXT NOT NULL,
|
|
||||||
"title" TEXT NOT NULL,
|
|
||||||
"content" TEXT,
|
|
||||||
"images" TEXT,
|
|
||||||
"record_date" DATETIME NOT NULL,
|
|
||||||
"created_by" INTEGER NOT NULL,
|
|
||||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updatedAt" DATETIME NOT NULL,
|
|
||||||
CONSTRAINT "growth_records_tenant_id_fkey" FOREIGN KEY ("tenant_id") REFERENCES "tenants" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "growth_records_student_id_fkey" FOREIGN KEY ("student_id") REFERENCES "students" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "growth_records_class_id_fkey" FOREIGN KEY ("class_id") REFERENCES "classes" ("id") ON DELETE SET NULL ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "tasks" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"tenant_id" INTEGER NOT NULL,
|
|
||||||
"title" TEXT NOT NULL,
|
|
||||||
"description" TEXT,
|
|
||||||
"task_type" TEXT NOT NULL,
|
|
||||||
"target_type" TEXT NOT NULL,
|
|
||||||
"related_course_id" INTEGER,
|
|
||||||
"created_by" INTEGER NOT NULL,
|
|
||||||
"start_date" DATETIME NOT NULL,
|
|
||||||
"end_date" DATETIME NOT NULL,
|
|
||||||
"status" TEXT NOT NULL DEFAULT 'PUBLISHED',
|
|
||||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updatedAt" DATETIME NOT NULL,
|
|
||||||
CONSTRAINT "tasks_tenant_id_fkey" FOREIGN KEY ("tenant_id") REFERENCES "tenants" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "tasks_related_course_id_fkey" FOREIGN KEY ("related_course_id") REFERENCES "courses" ("id") ON DELETE SET NULL ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "task_targets" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"task_id" INTEGER NOT NULL,
|
|
||||||
"class_id" INTEGER,
|
|
||||||
"student_id" INTEGER,
|
|
||||||
CONSTRAINT "task_targets_task_id_fkey" FOREIGN KEY ("task_id") REFERENCES "tasks" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "task_completions" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"task_id" INTEGER NOT NULL,
|
|
||||||
"student_id" INTEGER NOT NULL,
|
|
||||||
"status" TEXT NOT NULL DEFAULT 'PENDING',
|
|
||||||
"completed_at" DATETIME,
|
|
||||||
"feedback" TEXT,
|
|
||||||
"parent_feedback" TEXT,
|
|
||||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
CONSTRAINT "task_completions_task_id_fkey" FOREIGN KEY ("task_id") REFERENCES "tasks" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "task_completions_student_id_fkey" FOREIGN KEY ("student_id") REFERENCES "students" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "task_templates" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"tenant_id" INTEGER NOT NULL,
|
|
||||||
"name" TEXT NOT NULL,
|
|
||||||
"description" TEXT,
|
|
||||||
"task_type" TEXT NOT NULL,
|
|
||||||
"related_course_id" INTEGER,
|
|
||||||
"default_duration" INTEGER NOT NULL DEFAULT 7,
|
|
||||||
"is_default" BOOLEAN NOT NULL DEFAULT false,
|
|
||||||
"status" TEXT NOT NULL DEFAULT 'ACTIVE',
|
|
||||||
"created_by" INTEGER NOT NULL,
|
|
||||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updatedAt" DATETIME NOT NULL,
|
|
||||||
CONSTRAINT "task_templates_tenant_id_fkey" FOREIGN KEY ("tenant_id") REFERENCES "tenants" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "task_templates_related_course_id_fkey" FOREIGN KEY ("related_course_id") REFERENCES "courses" ("id") ON DELETE SET NULL ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "resource_libraries" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"name" TEXT NOT NULL,
|
|
||||||
"library_type" TEXT NOT NULL,
|
|
||||||
"description" TEXT,
|
|
||||||
"cover_image" TEXT,
|
|
||||||
"tenant_id" INTEGER,
|
|
||||||
"created_by" INTEGER NOT NULL,
|
|
||||||
"status" TEXT NOT NULL DEFAULT 'PUBLISHED',
|
|
||||||
"sort_order" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updatedAt" DATETIME NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "resource_items" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"library_id" INTEGER NOT NULL,
|
|
||||||
"title" TEXT NOT NULL,
|
|
||||||
"description" TEXT,
|
|
||||||
"file_type" TEXT NOT NULL,
|
|
||||||
"file_path" TEXT NOT NULL,
|
|
||||||
"file_size" INTEGER,
|
|
||||||
"tags" TEXT,
|
|
||||||
"sort_order" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
CONSTRAINT "resource_items_library_id_fkey" FOREIGN KEY ("library_id") REFERENCES "resource_libraries" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "system_settings" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"tenant_id" INTEGER NOT NULL,
|
|
||||||
"school_name" TEXT,
|
|
||||||
"school_logo" TEXT,
|
|
||||||
"address" TEXT,
|
|
||||||
"notify_on_lesson" BOOLEAN NOT NULL DEFAULT true,
|
|
||||||
"notify_on_task" BOOLEAN NOT NULL DEFAULT true,
|
|
||||||
"notify_on_growth" BOOLEAN NOT NULL DEFAULT false,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" DATETIME NOT NULL,
|
|
||||||
CONSTRAINT "system_settings_tenant_id_fkey" FOREIGN KEY ("tenant_id") REFERENCES "tenants" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "parents" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"tenant_id" INTEGER NOT NULL,
|
|
||||||
"name" TEXT NOT NULL,
|
|
||||||
"phone" TEXT NOT NULL,
|
|
||||||
"email" TEXT,
|
|
||||||
"login_account" TEXT NOT NULL,
|
|
||||||
"password_hash" TEXT NOT NULL,
|
|
||||||
"status" TEXT NOT NULL DEFAULT 'ACTIVE',
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" DATETIME NOT NULL,
|
|
||||||
"last_login_at" DATETIME,
|
|
||||||
CONSTRAINT "parents_tenant_id_fkey" FOREIGN KEY ("tenant_id") REFERENCES "tenants" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "parent_students" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"parent_id" INTEGER NOT NULL,
|
|
||||||
"student_id" INTEGER NOT NULL,
|
|
||||||
"relationship" TEXT NOT NULL,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
CONSTRAINT "parent_students_parent_id_fkey" FOREIGN KEY ("parent_id") REFERENCES "parents" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "parent_students_student_id_fkey" FOREIGN KEY ("student_id") REFERENCES "students" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "notifications" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"tenant_id" INTEGER NOT NULL,
|
|
||||||
"recipient_type" TEXT NOT NULL,
|
|
||||||
"recipient_id" INTEGER NOT NULL,
|
|
||||||
"title" TEXT NOT NULL,
|
|
||||||
"content" TEXT NOT NULL,
|
|
||||||
"notification_type" TEXT NOT NULL,
|
|
||||||
"related_type" TEXT,
|
|
||||||
"related_id" INTEGER,
|
|
||||||
"is_read" BOOLEAN NOT NULL DEFAULT false,
|
|
||||||
"read_at" DATETIME,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
CONSTRAINT "notifications_tenant_id_fkey" FOREIGN KEY ("tenant_id") REFERENCES "tenants" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "class_teachers" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"class_id" INTEGER NOT NULL,
|
|
||||||
"teacher_id" INTEGER NOT NULL,
|
|
||||||
"role" TEXT NOT NULL DEFAULT 'MAIN',
|
|
||||||
"isPrimary" BOOLEAN NOT NULL DEFAULT false,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" DATETIME NOT NULL,
|
|
||||||
CONSTRAINT "class_teachers_class_id_fkey" FOREIGN KEY ("class_id") REFERENCES "classes" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "class_teachers_teacher_id_fkey" FOREIGN KEY ("teacher_id") REFERENCES "teachers" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "student_class_history" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"student_id" INTEGER NOT NULL,
|
|
||||||
"from_class_id" INTEGER,
|
|
||||||
"to_class_id" INTEGER NOT NULL,
|
|
||||||
"reason" TEXT,
|
|
||||||
"operated_by" INTEGER,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
CONSTRAINT "student_class_history_student_id_fkey" FOREIGN KEY ("student_id") REFERENCES "students" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "student_class_history_from_class_id_fkey" FOREIGN KEY ("from_class_id") REFERENCES "classes" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "student_class_history_to_class_id_fkey" FOREIGN KEY ("to_class_id") REFERENCES "classes" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "schedule_plans" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"tenant_id" INTEGER NOT NULL,
|
|
||||||
"class_id" INTEGER NOT NULL,
|
|
||||||
"course_id" INTEGER NOT NULL,
|
|
||||||
"teacher_id" INTEGER,
|
|
||||||
"scheduled_date" DATETIME,
|
|
||||||
"scheduled_time" TEXT,
|
|
||||||
"week_day" INTEGER,
|
|
||||||
"repeat_type" TEXT NOT NULL DEFAULT 'NONE',
|
|
||||||
"repeat_end_date" DATETIME,
|
|
||||||
"source" TEXT NOT NULL DEFAULT 'SCHOOL',
|
|
||||||
"created_by" INTEGER NOT NULL,
|
|
||||||
"status" TEXT NOT NULL DEFAULT 'ACTIVE',
|
|
||||||
"note" TEXT,
|
|
||||||
"reminder_sent" BOOLEAN NOT NULL DEFAULT false,
|
|
||||||
"reminder_sent_at" DATETIME,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" DATETIME NOT NULL,
|
|
||||||
CONSTRAINT "schedule_plans_tenant_id_fkey" FOREIGN KEY ("tenant_id") REFERENCES "tenants" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "schedule_plans_class_id_fkey" FOREIGN KEY ("class_id") REFERENCES "classes" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "schedule_plans_course_id_fkey" FOREIGN KEY ("course_id") REFERENCES "courses" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "schedule_plans_teacher_id_fkey" FOREIGN KEY ("teacher_id") REFERENCES "teachers" ("id") ON DELETE SET NULL ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "schedule_templates" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"tenant_id" INTEGER NOT NULL,
|
|
||||||
"name" TEXT NOT NULL,
|
|
||||||
"course_id" INTEGER NOT NULL,
|
|
||||||
"class_id" INTEGER,
|
|
||||||
"teacher_id" INTEGER,
|
|
||||||
"scheduled_time" TEXT,
|
|
||||||
"week_day" INTEGER,
|
|
||||||
"duration" INTEGER NOT NULL DEFAULT 25,
|
|
||||||
"is_default" BOOLEAN NOT NULL DEFAULT false,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" DATETIME NOT NULL,
|
|
||||||
CONSTRAINT "schedule_templates_tenant_id_fkey" FOREIGN KEY ("tenant_id") REFERENCES "tenants" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "schedule_templates_course_id_fkey" FOREIGN KEY ("course_id") REFERENCES "courses" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "schedule_templates_class_id_fkey" FOREIGN KEY ("class_id") REFERENCES "classes" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "schedule_templates_teacher_id_fkey" FOREIGN KEY ("teacher_id") REFERENCES "teachers" ("id") ON DELETE SET NULL ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "operation_logs" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"tenant_id" INTEGER,
|
|
||||||
"user_id" INTEGER NOT NULL,
|
|
||||||
"user_type" TEXT NOT NULL,
|
|
||||||
"action" TEXT NOT NULL,
|
|
||||||
"module" TEXT NOT NULL,
|
|
||||||
"description" TEXT NOT NULL,
|
|
||||||
"target_id" INTEGER,
|
|
||||||
"old_value" TEXT,
|
|
||||||
"new_value" TEXT,
|
|
||||||
"ip_address" TEXT,
|
|
||||||
"user_agent" TEXT,
|
|
||||||
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
CONSTRAINT "operation_logs_tenant_id_fkey" FOREIGN KEY ("tenant_id") REFERENCES "tenants" ("id") ON DELETE SET NULL ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "tenants_login_account_key" ON "tenants"("login_account");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "teachers_login_account_key" ON "teachers"("login_account");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "courses_status_idx" ON "courses"("status");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "course_versions_course_id_idx" ON "course_versions"("course_id");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "course_scripts_course_id_step_index_key" ON "course_scripts"("course_id", "step_index");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "course_script_pages_script_id_page_number_key" ON "course_script_pages"("script_id", "page_number");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "lesson_feedbacks_lesson_id_teacher_id_key" ON "lesson_feedbacks"("lesson_id", "teacher_id");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "student_records_lesson_id_student_id_key" ON "student_records"("lesson_id", "student_id");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "tags_code_key" ON "tags"("code");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "tenant_courses_tenant_id_course_id_key" ON "tenant_courses"("tenant_id", "course_id");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "growth_records_tenant_id_student_id_idx" ON "growth_records"("tenant_id", "student_id");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "growth_records_tenant_id_class_id_idx" ON "growth_records"("tenant_id", "class_id");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "tasks_tenant_id_status_idx" ON "tasks"("tenant_id", "status");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "task_targets_task_id_class_id_idx" ON "task_targets"("task_id", "class_id");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "task_targets_task_id_student_id_idx" ON "task_targets"("task_id", "student_id");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "task_completions_task_id_student_id_key" ON "task_completions"("task_id", "student_id");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "task_templates_tenant_id_status_idx" ON "task_templates"("tenant_id", "status");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "resource_libraries_library_type_status_idx" ON "resource_libraries"("library_type", "status");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "resource_items_library_id_idx" ON "resource_items"("library_id");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "system_settings_tenant_id_key" ON "system_settings"("tenant_id");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "parents_login_account_key" ON "parents"("login_account");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "parent_students_parent_id_student_id_key" ON "parent_students"("parent_id", "student_id");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "notifications_tenant_id_recipient_type_recipient_id_idx" ON "notifications"("tenant_id", "recipient_type", "recipient_id");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "class_teachers_class_id_teacher_id_key" ON "class_teachers"("class_id", "teacher_id");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "schedule_plans_tenant_id_class_id_idx" ON "schedule_plans"("tenant_id", "class_id");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "schedule_plans_tenant_id_teacher_id_idx" ON "schedule_plans"("tenant_id", "teacher_id");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "schedule_plans_tenant_id_scheduled_date_idx" ON "schedule_plans"("tenant_id", "scheduled_date");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "schedule_templates_tenant_id_idx" ON "schedule_templates"("tenant_id");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "schedule_templates_tenant_id_course_id_idx" ON "schedule_templates"("tenant_id", "course_id");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "operation_logs_tenant_id_user_id_idx" ON "operation_logs"("tenant_id", "user_id");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "operation_logs_tenant_id_created_at_idx" ON "operation_logs"("tenant_id", "created_at");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "operation_logs_action_module_idx" ON "operation_logs"("action", "module");
|
|
||||||
37
reading-platform-frontend/src/components.d.ts
vendored
37
reading-platform-frontend/src/components.d.ts
vendored
@ -7,31 +7,68 @@ export {}
|
|||||||
|
|
||||||
declare module 'vue' {
|
declare module 'vue' {
|
||||||
export interface GlobalComponents {
|
export interface GlobalComponents {
|
||||||
|
AAlert: typeof import('ant-design-vue/es')['Alert']
|
||||||
AAvatar: typeof import('ant-design-vue/es')['Avatar']
|
AAvatar: typeof import('ant-design-vue/es')['Avatar']
|
||||||
ABadge: typeof import('ant-design-vue/es')['Badge']
|
ABadge: typeof import('ant-design-vue/es')['Badge']
|
||||||
AButton: typeof import('ant-design-vue/es')['Button']
|
AButton: typeof import('ant-design-vue/es')['Button']
|
||||||
ACard: typeof import('ant-design-vue/es')['Card']
|
ACard: typeof import('ant-design-vue/es')['Card']
|
||||||
|
ACheckbox: typeof import('ant-design-vue/es')['Checkbox']
|
||||||
ACol: typeof import('ant-design-vue/es')['Col']
|
ACol: typeof import('ant-design-vue/es')['Col']
|
||||||
|
ACollapse: typeof import('ant-design-vue/es')['Collapse']
|
||||||
|
ACollapsePanel: typeof import('ant-design-vue/es')['CollapsePanel']
|
||||||
|
ADatePicker: typeof import('ant-design-vue/es')['DatePicker']
|
||||||
|
ADescriptions: typeof import('ant-design-vue/es')['Descriptions']
|
||||||
|
ADescriptionsItem: typeof import('ant-design-vue/es')['DescriptionsItem']
|
||||||
|
ADivider: typeof import('ant-design-vue/es')['Divider']
|
||||||
ADrawer: typeof import('ant-design-vue/es')['Drawer']
|
ADrawer: typeof import('ant-design-vue/es')['Drawer']
|
||||||
ADropdown: typeof import('ant-design-vue/es')['Dropdown']
|
ADropdown: typeof import('ant-design-vue/es')['Dropdown']
|
||||||
AEmpty: typeof import('ant-design-vue/es')['Empty']
|
AEmpty: typeof import('ant-design-vue/es')['Empty']
|
||||||
AForm: typeof import('ant-design-vue/es')['Form']
|
AForm: typeof import('ant-design-vue/es')['Form']
|
||||||
AFormItem: typeof import('ant-design-vue/es')['FormItem']
|
AFormItem: typeof import('ant-design-vue/es')['FormItem']
|
||||||
|
AImage: typeof import('ant-design-vue/es')['Image']
|
||||||
|
AImagePreviewGroup: typeof import('ant-design-vue/es')['ImagePreviewGroup']
|
||||||
AInput: typeof import('ant-design-vue/es')['Input']
|
AInput: typeof import('ant-design-vue/es')['Input']
|
||||||
|
AInputNumber: typeof import('ant-design-vue/es')['InputNumber']
|
||||||
AInputPassword: typeof import('ant-design-vue/es')['InputPassword']
|
AInputPassword: typeof import('ant-design-vue/es')['InputPassword']
|
||||||
|
AInputSearch: typeof import('ant-design-vue/es')['InputSearch']
|
||||||
ALayout: typeof import('ant-design-vue/es')['Layout']
|
ALayout: typeof import('ant-design-vue/es')['Layout']
|
||||||
ALayoutContent: typeof import('ant-design-vue/es')['LayoutContent']
|
ALayoutContent: typeof import('ant-design-vue/es')['LayoutContent']
|
||||||
ALayoutHeader: typeof import('ant-design-vue/es')['LayoutHeader']
|
ALayoutHeader: typeof import('ant-design-vue/es')['LayoutHeader']
|
||||||
ALayoutSider: typeof import('ant-design-vue/es')['LayoutSider']
|
ALayoutSider: typeof import('ant-design-vue/es')['LayoutSider']
|
||||||
|
AList: typeof import('ant-design-vue/es')['List']
|
||||||
|
AListItem: typeof import('ant-design-vue/es')['ListItem']
|
||||||
|
AListItemMeta: typeof import('ant-design-vue/es')['ListItemMeta']
|
||||||
AMenu: typeof import('ant-design-vue/es')['Menu']
|
AMenu: typeof import('ant-design-vue/es')['Menu']
|
||||||
AMenuDivider: typeof import('ant-design-vue/es')['MenuDivider']
|
AMenuDivider: typeof import('ant-design-vue/es')['MenuDivider']
|
||||||
AMenuItem: typeof import('ant-design-vue/es')['MenuItem']
|
AMenuItem: typeof import('ant-design-vue/es')['MenuItem']
|
||||||
|
AModal: typeof import('ant-design-vue/es')['Modal']
|
||||||
|
APageHeader: typeof import('ant-design-vue/es')['PageHeader']
|
||||||
|
APagination: typeof import('ant-design-vue/es')['Pagination']
|
||||||
|
APopconfirm: typeof import('ant-design-vue/es')['Popconfirm']
|
||||||
|
AProgress: typeof import('ant-design-vue/es')['Progress']
|
||||||
|
ARadio: typeof import('ant-design-vue/es')['Radio']
|
||||||
|
ARadioGroup: typeof import('ant-design-vue/es')['RadioGroup']
|
||||||
ARangePicker: typeof import('ant-design-vue/es')['RangePicker']
|
ARangePicker: typeof import('ant-design-vue/es')['RangePicker']
|
||||||
|
ARate: typeof import('ant-design-vue/es')['Rate']
|
||||||
ARow: typeof import('ant-design-vue/es')['Row']
|
ARow: typeof import('ant-design-vue/es')['Row']
|
||||||
|
ASelect: typeof import('ant-design-vue/es')['Select']
|
||||||
|
ASelectOption: typeof import('ant-design-vue/es')['SelectOption']
|
||||||
|
ASkeleton: typeof import('ant-design-vue/es')['Skeleton']
|
||||||
ASpace: typeof import('ant-design-vue/es')['Space']
|
ASpace: typeof import('ant-design-vue/es')['Space']
|
||||||
ASpin: typeof import('ant-design-vue/es')['Spin']
|
ASpin: typeof import('ant-design-vue/es')['Spin']
|
||||||
|
AStatistic: typeof import('ant-design-vue/es')['Statistic']
|
||||||
ASubMenu: typeof import('ant-design-vue/es')['SubMenu']
|
ASubMenu: typeof import('ant-design-vue/es')['SubMenu']
|
||||||
|
ASwitch: typeof import('ant-design-vue/es')['Switch']
|
||||||
|
ATable: typeof import('ant-design-vue/es')['Table']
|
||||||
|
ATabPane: typeof import('ant-design-vue/es')['TabPane']
|
||||||
|
ATabs: typeof import('ant-design-vue/es')['Tabs']
|
||||||
ATag: typeof import('ant-design-vue/es')['Tag']
|
ATag: typeof import('ant-design-vue/es')['Tag']
|
||||||
|
ATextarea: typeof import('ant-design-vue/es')['Textarea']
|
||||||
|
ATimeRangePicker: typeof import('ant-design-vue/es')['TimeRangePicker']
|
||||||
|
ATooltip: typeof import('ant-design-vue/es')['Tooltip']
|
||||||
|
ATypographyText: typeof import('ant-design-vue/es')['TypographyText']
|
||||||
|
AUpload: typeof import('ant-design-vue/es')['Upload']
|
||||||
|
AUploadDragger: typeof import('ant-design-vue/es')['UploadDragger']
|
||||||
FilePreviewModal: typeof import('./components/FilePreviewModal.vue')['default']
|
FilePreviewModal: typeof import('./components/FilePreviewModal.vue')['default']
|
||||||
FileUploader: typeof import('./components/course/FileUploader.vue')['default']
|
FileUploader: typeof import('./components/course/FileUploader.vue')['default']
|
||||||
LessonConfigPanel: typeof import('./components/course/LessonConfigPanel.vue')['default']
|
LessonConfigPanel: typeof import('./components/course/LessonConfigPanel.vue')['default']
|
||||||
|
|||||||
@ -119,9 +119,9 @@ const roles = [
|
|||||||
|
|
||||||
const testAccounts = [
|
const testAccounts = [
|
||||||
{ role: 'admin', label: '超管', account: 'admin', password: 'admin123' },
|
{ role: 'admin', label: '超管', account: 'admin', password: 'admin123' },
|
||||||
{ role: 'school', label: '学校', account: 'school', password: '123456' },
|
{ role: 'school', label: '学校', account: 'nanshan', password: 'nanshan123456' },
|
||||||
{ role: 'teacher', label: '教师', account: 'teacher1', password: '123456' },
|
{ role: 'teacher', label: '教师', account: 'nanshanTeacher', password: 'teache123456' },
|
||||||
{ role: 'parent', label: '家长', account: 'parent1', password: '123456' },
|
{ role: 'parent', label: '家长', account: 'user', password: 'user123456' },
|
||||||
];
|
];
|
||||||
|
|
||||||
const formState = reactive({
|
const formState = reactive({
|
||||||
|
|||||||
@ -18,35 +18,36 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="sider-menu-wrap">
|
<div class="sider-menu-wrap">
|
||||||
<a-menu
|
<a-menu
|
||||||
v-model:selectedKeys="selectedKeys"
|
v-model:selectedKeys="selectedKeys"
|
||||||
mode="inline"
|
mode="inline"
|
||||||
theme="light"
|
theme="light"
|
||||||
:inline-collapsed="collapsed"
|
:inline-collapsed="collapsed"
|
||||||
@click="handleMenuClick"
|
@click="handleMenuClick"
|
||||||
class="side-menu"
|
class="side-menu"
|
||||||
>
|
>
|
||||||
<a-menu-item key="dashboard">
|
<a-menu-item key="dashboard">
|
||||||
<template #icon><HomeOutlined /></template>
|
<template #icon><HomeOutlined /></template>
|
||||||
<span>首页</span>
|
<span>首页</span>
|
||||||
</a-menu-item>
|
</a-menu-item>
|
||||||
<a-menu-item key="children">
|
<a-menu-item key="children">
|
||||||
<template #icon><TeamOutlined /></template>
|
<template #icon><TeamOutlined /></template>
|
||||||
<span>我的孩子</span>
|
<span>我的孩子</span>
|
||||||
</a-menu-item>
|
</a-menu-item>
|
||||||
<a-menu-item key="lessons">
|
<a-menu-item key="lessons">
|
||||||
<template #icon><BookOutlined /></template>
|
<template #icon><BookOutlined /></template>
|
||||||
<span>阅读记录</span>
|
<span>阅读记录</span>
|
||||||
</a-menu-item>
|
</a-menu-item>
|
||||||
<a-menu-item key="tasks">
|
<a-menu-item key="tasks">
|
||||||
<template #icon><CheckSquareOutlined /></template>
|
<template #icon><CheckSquareOutlined /></template>
|
||||||
<span>阅读任务</span>
|
<span>阅读任务</span>
|
||||||
</a-menu-item>
|
</a-menu-item>
|
||||||
<a-menu-item key="growth">
|
<a-menu-item key="growth">
|
||||||
<template #icon><FileImageOutlined /></template>
|
<template #icon><FileImageOutlined /></template>
|
||||||
<span>成长档案</span>
|
<span>成长档案</span>
|
||||||
</a-menu-item>
|
</a-menu-item>
|
||||||
</a-menu>
|
</a-menu>
|
||||||
|
</div>
|
||||||
</a-layout-sider>
|
</a-layout-sider>
|
||||||
|
|
||||||
<!-- 移动端抽屉菜单 -->
|
<!-- 移动端抽屉菜单 -->
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user