46 lines
2 KiB
PL/PgSQL
46 lines
2 KiB
PL/PgSQL
-- Development data. Apply with:
|
|
-- psql "$DATABASE_URL" -f db/seed.sql
|
|
BEGIN;
|
|
|
|
INSERT INTO public.users (id, external_id, firstname, "name", email, oidc_sub, admin) VALUES
|
|
(1, '100001', 'Alice', 'Martin', 'alice.martin@epfl.ch', 'oidc-sub-alice', TRUE),
|
|
(2, '100002', 'Bob', 'Dupont', 'bob.dupont@epfl.ch', 'oidc-sub-bob', FALSE),
|
|
(3, NULL, 'Chloé', 'Favre', 'chloe.favre@epfl.ch', 'oidc-sub-chloe', FALSE)
|
|
ON CONFLICT DO NOTHING;
|
|
|
|
-- Unit names come from Whiskey; these are placeholders for development
|
|
INSERT INTO public.units_users (user_id, unit_name) VALUES
|
|
(1, 'agepoly'),
|
|
(2, 'agepoly'),
|
|
(2, 'clic'),
|
|
(3, 'clic')
|
|
ON CONFLICT DO NOTHING;
|
|
|
|
INSERT INTO public.bikes (id, "name", key_number, key_quantity, drivetrain, battery, status) VALUES
|
|
(1, 'Cargo 1', 'K-1042', 2, 'Shimano Nexus 8', 'BAT-A12', 'in_service'),
|
|
(2, 'Cargo 2', 'K-1043', 2, 'Shimano Nexus 8', 'BAT-A13', 'in_service'),
|
|
(3, 'Cargo 3', 'K-1044', 1, 'Rohloff Speedhub', NULL, 'out_of_service')
|
|
ON CONFLICT DO NOTHING;
|
|
|
|
INSERT INTO public.reservations
|
|
(id, unit, start_time, end_time, requester_id, telegram, "description", status) VALUES
|
|
(1, 'agepoly', '2026-09-01 08:00:00+02', '2026-09-01 18:00:00+02', 1, '@alice_martin',
|
|
'Transport du matériel pour la rentrée', 'approved'),
|
|
(2, 'clic', '2026-09-05 09:00:00+02', '2026-09-06 17:00:00+02', 3, '@chloe_favre',
|
|
'Déménagement du stock de la commission', 'requested')
|
|
ON CONFLICT DO NOTHING;
|
|
|
|
INSERT INTO public.reservations_users (reservation_id, user_id) VALUES
|
|
(1, 1), (1, 2), (2, 3)
|
|
ON CONFLICT DO NOTHING;
|
|
|
|
INSERT INTO public.reservations_bikes (reservation_id, bike_id) VALUES
|
|
(1, 1), (1, 2), (2, 1)
|
|
ON CONFLICT DO NOTHING;
|
|
|
|
-- Keep the sequences in sync with the explicit ids inserted above
|
|
SELECT setval('public.users_id_seq', (SELECT COALESCE(MAX(id), 1) FROM public.users));
|
|
SELECT setval('public.bikes_id_seq', (SELECT COALESCE(MAX(id), 1) FROM public.bikes));
|
|
SELECT setval('public.reservations_id_seq', (SELECT COALESCE(MAX(id), 1) FROM public.reservations));
|
|
|
|
COMMIT;
|