-
Notifications
You must be signed in to change notification settings - Fork 21
Collapse file tree
Files
Search this repository
/
Copy pathseed.sql
More file actions
More file actions
Latest commit
/
seed.sql
File metadata and controls
You must be signed in to make or propose changes
More edit options
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
-- Seed file for local development
--
-- To create an admin user:
-- 1. Run this seed file with: npx supabase db reset
-- 2. The admin user will be created with email: admin@example.com
-- 3. Password: admin123456
-- Create admin user for local development
-- Note: We use crypt() function from pgcrypto extension to hash the password
INSERT INTO auth.users (
instance_id,
id,
aud,
role,
email,
encrypted_password,
email_confirmed_at,
raw_app_meta_data,
raw_user_meta_data,
created_at,
updated_at,
confirmation_token,
email_change,
email_change_token_new,
recovery_token
) VALUES (
'00000000-0000-0000-0000-000000000000',
gen_random_uuid(),
'authenticated',
'authenticated',
'admin@example.com',
crypt('admin123456', gen_salt('bf')),
NOW(),
'{"provider":"email","providers":["email"]}'::jsonb,
'{}'::jsonb,
NOW(),
NOW(),
'',
'',
'',
''
);
-- Create identity record for the user
INSERT INTO auth.identities (
id,
user_id,
provider_id,
identity_data,
provider,
last_sign_in_at,
created_at,
updated_at
)
SELECT
gen_random_uuid(),
id,
id::text,
format('{"sub":"%s","email":"%s"}', id::text, email)::jsonb,
'email',
NOW(),
NOW(),
NOW()
FROM auth.users
WHERE email = 'admin@example.com';
-- Grant admin role to the user
UPDATE auth.users
SET raw_app_meta_data = raw_app_meta_data || '{"roles": ["admin"]}'::jsonb
WHERE email = 'admin@example.com';