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
@@ -684,3 +684,27 @@ INSERT INTO settings (key, value) VALUES ('face_scan_on_upload', 'true') ON CONF
INSERT INTO settings (key, value) VALUES ('notify_face_scan_done', 'false') ON CONFLICT (key) DO NOTHING;
INSERT INTO settings (key, value) VALUES ('notify_face_recognized', 'true') ON CONFLICT (key) DO NOTHING;
INSERT INTO settings (key, value) VALUES ('notify_face_scan_error', 'true') ON CONFLICT (key) DO NOTHING;
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);