mirror of
https://github.com/SECTL/SecScore.git
synced 2026-07-21 18:19:03 +08:00
feat:自动加分更新逻辑
This commit is contained in:
@@ -81,6 +81,47 @@ export class InitSchema2026011800000 implements MigrationInterface {
|
||||
('迟到','纪律',-1,1,CURRENT_TIMESTAMP),
|
||||
('未交作业','作业情况',-2,1,CURRENT_TIMESTAMP)
|
||||
`)
|
||||
|
||||
if (!(await queryRunner.hasTable('tags'))) {
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE "tags" (
|
||||
"id" integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
"name" text NOT NULL UNIQUE,
|
||||
"created_at" text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
||||
"updated_at" text NOT NULL DEFAULT (CURRENT_TIMESTAMP)
|
||||
)
|
||||
`)
|
||||
}
|
||||
|
||||
if (!(await queryRunner.hasTable('student_tags'))) {
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE "student_tags" (
|
||||
"id" integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
"student_id" integer NOT NULL,
|
||||
"tag_id" integer NOT NULL,
|
||||
"created_at" text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
||||
FOREIGN KEY ("student_id") REFERENCES "students"("id") ON DELETE CASCADE,
|
||||
FOREIGN KEY ("tag_id") REFERENCES "tags"("id") ON DELETE CASCADE,
|
||||
UNIQUE("student_id", "tag_id")
|
||||
)
|
||||
`)
|
||||
}
|
||||
|
||||
await queryRunner.query(
|
||||
`CREATE INDEX IF NOT EXISTS "IDX_student_tags_student_id" ON "student_tags" ("student_id")`
|
||||
)
|
||||
await queryRunner.query(
|
||||
`CREATE INDEX IF NOT EXISTS "IDX_student_tags_tag_id" ON "student_tags" ("tag_id")`
|
||||
)
|
||||
|
||||
await queryRunner.query(`
|
||||
INSERT OR IGNORE INTO "tags" ("name") VALUES
|
||||
('优秀生'),
|
||||
('班干部'),
|
||||
('勤奋'),
|
||||
('活跃'),
|
||||
('进步快')
|
||||
`)
|
||||
}
|
||||
|
||||
async down(queryRunner: QueryRunner): Promise<void> {
|
||||
@@ -89,5 +130,7 @@ export class InitSchema2026011800000 implements MigrationInterface {
|
||||
await queryRunner.query(`DROP TABLE IF EXISTS "students"`)
|
||||
await queryRunner.query(`DROP TABLE IF EXISTS "reasons"`)
|
||||
await queryRunner.query(`DROP TABLE IF EXISTS "settings"`)
|
||||
await queryRunner.query(`DROP TABLE IF EXISTS "student_tags"`)
|
||||
await queryRunner.query(`DROP TABLE IF EXISTS "tags"`)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user