static data for Courses

This commit is contained in:
Yared Yemane 2026-04-23 02:07:32 -07:00
parent 9db9c9899a
commit 6c672c4b20
3 changed files with 26 additions and 1 deletions

View File

@ -0,0 +1,3 @@
DELETE FROM courses
WHERE description = 'Default CEFR level course (system seed).'
AND name IN ('A1', 'A2', 'B1', 'B2', 'C1', 'C2');

View File

@ -0,0 +1,18 @@
-- Default CEFR-style course names per program (custom courses can still be created via the API with any name).
-- Matches hierarchy note on courses: CEFR labels A1..C2, plus ad-hoc names allowed.
INSERT INTO courses (program_id, name, description, thumbnail)
SELECT
p.id,
v.name,
'Default CEFR level course (system seed).',
NULL
FROM programs AS p
CROSS JOIN (
VALUES
('A1'),
('A2'),
('B1'),
('B2'),
('C1'),
('C2')
) AS v (name);

View File

@ -2,7 +2,11 @@ package domain
import "time" import "time"
// Course belongs to a Program (e.g. A1, A2, … labels are configured separately). // DefaultCEFRCourseNames are the standard course names seeded for each program (migration 000048).
// Creating a course via the API may use any of these or a custom name.
var DefaultCEFRCourseNames = []string{"A1", "A2", "B1", "B2", "C1", "C2"}
// Course belongs to a Program.
type Course struct { type Course struct {
ID int64 `json:"id"` ID int64 `json:"id"`
ProgramID int64 `json:"program_id"` ProgramID int64 `json:"program_id"`