feat: student achievements (admin-managed types + per-student records, UI & backup)

This commit is contained in:
dev
2026-10-27 13:02:56 +03:00
parent 2bc96aaecc
commit 12034812ec
12 changed files with 1067 additions and 6 deletions
+24
View File
@@ -921,3 +921,27 @@ CREATE TABLE IF NOT EXISTS doc_images (
CREATE INDEX IF NOT EXISTS idx_doc_images_article ON doc_images(article_id);
CREATE INDEX IF NOT EXISTS idx_doc_images_path ON doc_images(path);
CREATE TABLE IF NOT EXISTS achievement_types (
id SERIAL PRIMARY KEY,
name VARCHAR(150) NOT NULL,
sort_order INT NOT NULL DEFAULT 0,
is_active BOOLEAN NOT NULL DEFAULT true,
created_at TIMESTAMPTZ DEFAULT now(),
updated_at TIMESTAMPTZ DEFAULT now()
);
CREATE UNIQUE INDEX IF NOT EXISTS idx_achievement_types_name ON achievement_types(lower(name));
CREATE INDEX IF NOT EXISTS idx_achievement_types_order ON achievement_types(sort_order, id);
CREATE TABLE IF NOT EXISTS student_achievements (
id SERIAL PRIMARY KEY,
student_id INT NOT NULL REFERENCES students(id) ON DELETE CASCADE,
type_name VARCHAR(150) NOT NULL,
value VARCHAR(200) NOT NULL DEFAULT '',
achieved_at DATE,
note TEXT NOT NULL DEFAULT '',
author_id INT REFERENCES users(id) ON DELETE SET NULL,
created_at TIMESTAMPTZ DEFAULT now(),
updated_at TIMESTAMPTZ DEFAULT now()
);
CREATE INDEX IF NOT EXISTS idx_student_achievements_student ON student_achievements(student_id);