Audrow
07/26/2022, 3:42 PMseed.sql file in my supabase directory that gets run when I reset the database using the Supabase CLI (local development). That seed file does something like this:
sql
DO $$
DECLARE user_1_id uuid;
DECLARE user_2_id uuid;
BEGIN
user_1_id := uuid_generate_v4();
user_2_id := uuid_generate_v4();
INSERT INTO auth.users (id, email, created_at, updated_at)
VALUES
(user_1_id, 'audrow@hey.com', now(), now()),
(user_2_id, 'not-audrow@hey.com', now(), now());
-- use user_1_id and user_2_id in other tables
$$;
With this setup, I see the two users in my database, but I cannot login with them (I get a generic database error) and cannot email them a login link or reset their password.
I think that I can probably do what I want with a JS script that uses my Supabase client, but don't know how to use a JS file to seed the database automatically each time I reset the database.Needle
07/26/2022, 3:42 PMjaitaiwan
07/26/2022, 3:59 PMAudrow
07/27/2022, 3:48 PMsql
INSERT INTO auth.users (id, instance_id, email, created_at, updated_at, email_confirmed_at, recovery_sent_at, last_sign_in_at, raw_app_meta_data, aud, role, encrypted_password, raw_user_meta_data, is_super_admin, confirmation_token, email_change_token_new, email_change)
VALUES
(user_1_id, uuid_generate_v4(), 'audrow@hey.com', now(), now(), now(), now(), now(), email_raw_meta_data, 'authenticated', 'authenticated', '$2a$10$X', '{}', false, '', '', ''),
(user_2_id, uuid_generate_v4(), 'not-audrow@hey.com', now(), now(), now(), now(), now(), email_raw_meta_data, 'authenticated', 'authenticated', '$2a$10$X', '{}', false, '', '', '');
I'm only modifying auth.users. I'm not sure if other databases are modified. I think I'll make a JS script to populate users and data.Audrow
07/27/2022, 3:48 PMAudrow
07/29/2022, 3:47 PMpg_dump postgresql://postgres:postgres@localhost:54322/postgres -t auth.users --insert --data-only > supabase/seed.sql
This way, I don't have to run a javascript file, and I can have data to test my application with.Needle
07/29/2022, 3:47 PM