studium/db/seed.sql
Antoine Pelletier 07d98b64b3 first commit
2026-09-28 12:04:47 +02:00

25 lines
1.1 KiB
PL/PgSQL

-- Development data. Apply with:
-- psql "$DATABASE_URL" -f db/seed.sql
BEGIN;
INSERT INTO public.courses (id, "name", code, teachers, main_page_url) VALUES
(1, 'Advanced operating systems', 'CS-477', '{"Alice Martin"}', 'https://moodle.epfl.ch'),
(2, 'Machine learning', 'CS-433', '{"Bruno Keller", "Claire Dubois"}', NULL),
(3, 'Computer networks', 'COM-208', '{"David Rossi"}', NULL)
ON CONFLICT DO NOTHING;
-- Tags 1, 2, 3 = lecture, exercises, lab (created by the migration)
INSERT INTO public.time_slots (id, course_id, tag_id, weekday, start_time, end_time) VALUES
(1, 1, 1, 1, '10:15', '12:00'),
(2, 1, 3, 3, '13:15', '15:00'),
(3, 2, 1, 2, '08:15', '10:00'),
(4, 2, 2, 4, '14:15', '16:00'),
(5, 3, 1, 1, '11:15', '13:00'),
(6, 3, 2, 4, '15:15', '17:00')
ON CONFLICT DO NOTHING;
-- Keep the sequences in sync with the explicit ids inserted above
SELECT setval('public.courses_id_seq', (SELECT COALESCE(MAX(id), 1) FROM public.courses));
SELECT setval('public.time_slots_id_seq', (SELECT COALESCE(MAX(id), 1) FROM public.time_slots));
COMMIT;