package demoseed import _ "embed" //go:embed makeup_profile_options.sql var makeupProfileOptionsSQL string func (s seed) seedMakeupProfileOptions() error { _, err := s.tx.Exec(s.ctx, makeupProfileOptionsSQL+"\n"+makeupFocusOptionsSQL) return err } // Archive only untouched, seed-owned general-learning fixtures. Existing IDs, // descendants and progress remain available to staff. Timestamp checks also // protect fixtures to which staff have added or edited learning content. func (s seed) archiveLegacyCourses() error { legacy := []struct{ key, name, description string }{ {"everyday-english", "Everyday English", "Build confidence with introductions, daily conversations, and practical vocabulary."}, {"workplace-communication", "Workplace Communication", "Communicate clearly in meetings, write effective messages, and present your ideas."}, {"digital-skills", "Digital Skills Essentials", "Learn practical habits for working online, organizing information, and collaborating safely."}, } for _, old := range legacy { _, err := s.tx.Exec(s.ctx, `UPDATE exam_prep.catalog_courses c SET publish_status='DRAFT',updated_at=NOW() FROM demo_seed_entities d WHERE d.kind='course' AND d.seed_key=$1 AND c.id=d.entity_id AND c.name=$2 AND c.description=$3 AND c.updated_at IS NULL AND NOT EXISTS(SELECT 1 FROM exam_prep.units u WHERE u.catalog_course_id=c.id AND (u.updated_at IS NOT NULL OR u.created_at>c.created_at)) AND NOT EXISTS(SELECT 1 FROM exam_prep.unit_modules m JOIN exam_prep.units u ON u.id=m.unit_id WHERE u.catalog_course_id=c.id AND (m.updated_at IS NOT NULL OR m.created_at>c.created_at)) AND NOT EXISTS(SELECT 1 FROM exam_prep.unit_module_lessons l JOIN exam_prep.unit_modules m ON m.id=l.unit_module_id JOIN exam_prep.units u ON u.id=m.unit_id WHERE u.catalog_course_id=c.id AND (l.updated_at IS NOT NULL OR l.created_at>c.created_at)) AND NOT EXISTS(SELECT 1 FROM exam_prep.lesson_practices p JOIN exam_prep.practice_parents pp ON pp.practice_id=p.id JOIN question_sets qs ON qs.id=p.question_set_id WHERE ((pp.parent_kind='CATALOG_COURSE' AND pp.parent_id=c.id) OR (pp.parent_kind='UNIT' AND pp.parent_id IN(SELECT id FROM exam_prep.units WHERE catalog_course_id=c.id)) OR (pp.parent_kind='LESSON' AND pp.parent_id IN(SELECT l.id FROM exam_prep.unit_module_lessons l JOIN exam_prep.unit_modules m ON m.id=l.unit_module_id JOIN exam_prep.units u ON u.id=m.unit_id WHERE u.catalog_course_id=c.id))) AND (p.updated_at IS NOT NULL OR p.created_at>c.created_at OR qs.updated_at IS NOT NULL OR qs.created_at>c.created_at OR EXISTS(SELECT 1 FROM question_set_items i JOIN questions q ON q.id=i.question_id WHERE i.set_id=qs.id AND (q.updated_at IS NOT NULL OR q.created_at>c.created_at OR EXISTS(SELECT 1 FROM question_options o WHERE o.question_id=q.id AND o.created_at>c.created_at)))))`, old.key, old.name, old.description) if err != nil { return err } } return nil } func (s seed) refreshLegacyDemoLabels() error { _, err := s.tx.Exec(s.ctx, `UPDATE subscription_plans p SET name='[Demo] Makeup Academy Pass',description='Testing only: grants premium makeup artistry course access for 30 days.' FROM demo_seed_entities d WHERE d.kind='plan' AND d.seed_key='education-demo' AND p.id=d.entity_id AND p.name='[Demo] Education access' AND p.description='Testing only: grants premium learning access for 30 days.'`) if err != nil { return err } _, err = s.tx.Exec(s.ctx, `UPDATE exam_prep.catalog_courses c SET name='[Demo draft] Special Effects Makeup',description='Unpublished makeup artistry course: must not appear in the public catalog.' FROM demo_seed_entities d WHERE d.kind='course' AND d.seed_key='draft' AND c.id=d.entity_id AND c.name='[Demo draft] Coming soon' AND c.description='Unpublished fixture: must not appear in the public catalog.' AND c.updated_at IS NULL`) return err } //go:embed makeup_focus_options.sql var makeupFocusOptionsSQL string