From 89ea85bbf863fcb588ba0eb8f417e62f58a9aac0 Mon Sep 17 00:00:00 2001 From: ordinarthur <@arthurbarre.js@gmail.com> Date: Sun, 12 Apr 2026 12:34:13 +0200 Subject: [PATCH] change seed --- supabase/seed.sql | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/supabase/seed.sql b/supabase/seed.sql index 89d20da..35996d5 100644 --- a/supabase/seed.sql +++ b/supabase/seed.sql @@ -4,11 +4,27 @@ -- Source: Hacker Public Radio (archive.org) -- ============================================== --- 1. Create demo users (fake auth entries then profiles) +-- 1. Create demo users in auth.users first (required for FK on profiles) -- NOTE: Run this AFTER the migration 001_initial_schema.sql --- Insert profiles directly (these won't have auth.users entries, --- but work for display purposes) +INSERT INTO auth.users (id, instance_id, email, encrypted_password, email_confirmed_at, aud, role, raw_app_meta_data, raw_user_meta_data, created_at, updated_at, confirmation_token) VALUES + ('a1000000-0000-0000-0000-000000000001', '00000000-0000-0000-0000-000000000000', 'ahuka@demo.wetalk.fr', crypt('demo-password-123', gen_salt('bf')), NOW(), 'authenticated', 'authenticated', '{"provider":"email","providers":["email"]}', '{"username":"ahuka"}', NOW(), NOW(), ''), + ('a1000000-0000-0000-0000-000000000002', '00000000-0000-0000-0000-000000000000', 'sgoti@demo.wetalk.fr', crypt('demo-password-123', gen_salt('bf')), NOW(), 'authenticated', 'authenticated', '{"provider":"email","providers":["email"]}', '{"username":"sgoti"}', NOW(), NOW(), ''), + ('a1000000-0000-0000-0000-000000000003', '00000000-0000-0000-0000-000000000000', 'klaatu@demo.wetalk.fr', crypt('demo-password-123', gen_salt('bf')), NOW(), 'authenticated', 'authenticated', '{"provider":"email","providers":["email"]}', '{"username":"klaatu"}', NOW(), NOW(), ''), + ('a1000000-0000-0000-0000-000000000004', '00000000-0000-0000-0000-000000000000', 'windigo@demo.wetalk.fr', crypt('demo-password-123', gen_salt('bf')), NOW(), 'authenticated', 'authenticated', '{"provider":"email","providers":["email"]}', '{"username":"windigo"}', NOW(), NOW(), ''), + ('a1000000-0000-0000-0000-000000000005', '00000000-0000-0000-0000-000000000000', 'corydoctorow@demo.wetalk.fr', crypt('demo-password-123', gen_salt('bf')), NOW(), 'authenticated', 'authenticated', '{"provider":"email","providers":["email"]}', '{"username":"corydoctorow"}', NOW(), NOW(), '') +ON CONFLICT (id) DO NOTHING; + +-- Also insert into auth.identities (required by Supabase Auth) +INSERT INTO auth.identities (id, user_id, provider_id, provider, identity_data, last_sign_in_at, created_at, updated_at) VALUES + ('a1000000-0000-0000-0000-000000000001', 'a1000000-0000-0000-0000-000000000001', 'a1000000-0000-0000-0000-000000000001', 'email', '{"sub":"a1000000-0000-0000-0000-000000000001","email":"ahuka@demo.wetalk.fr"}', NOW(), NOW(), NOW()), + ('a1000000-0000-0000-0000-000000000002', 'a1000000-0000-0000-0000-000000000002', 'a1000000-0000-0000-0000-000000000002', 'email', '{"sub":"a1000000-0000-0000-0000-000000000002","email":"sgoti@demo.wetalk.fr"}', NOW(), NOW(), NOW()), + ('a1000000-0000-0000-0000-000000000003', 'a1000000-0000-0000-0000-000000000003', 'a1000000-0000-0000-0000-000000000003', 'email', '{"sub":"a1000000-0000-0000-0000-000000000003","email":"klaatu@demo.wetalk.fr"}', NOW(), NOW(), NOW()), + ('a1000000-0000-0000-0000-000000000004', 'a1000000-0000-0000-0000-000000000004', 'a1000000-0000-0000-0000-000000000004', 'email', '{"sub":"a1000000-0000-0000-0000-000000000004","email":"windigo@demo.wetalk.fr"}', NOW(), NOW(), NOW()), + ('a1000000-0000-0000-0000-000000000005', 'a1000000-0000-0000-0000-000000000005', 'a1000000-0000-0000-0000-000000000005', 'email', '{"sub":"a1000000-0000-0000-0000-000000000005","email":"corydoctorow@demo.wetalk.fr"}', NOW(), NOW(), NOW()) +ON CONFLICT (id) DO NOTHING; + +-- Now insert profiles (the trigger handle_new_user won't fire on direct auth.users inserts) INSERT INTO public.profiles (id, username, avatar_url, bio, is_premium, free_listens_count) VALUES ('a1000000-0000-0000-0000-000000000001', 'ahuka', NULL, 'Passionné de technologie et de logiciels libres. Contributeur Hacker Public Radio.', true, 0), ('a1000000-0000-0000-0000-000000000002', 'sgoti', NULL, 'Podcaster et bricoleur informatique. J''aime parler de tout et de rien.', false, 3),