-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-admin-user.sql
More file actions
30 lines (25 loc) · 955 Bytes
/
create-admin-user.sql
File metadata and controls
30 lines (25 loc) · 955 Bytes
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
-- Create admin user for michaelvx@gmail.com
-- Run this in Supabase SQL Editor
-- First, check if user exists
SELECT id, email, role FROM users WHERE email = 'michaelvx@gmail.com';
-- If user doesn't exist, we need to get the auth user ID first
-- You can find this in Supabase Dashboard > Authentication > Users
-- Option 1: If user exists in auth.users but not in public.users
INSERT INTO public.users (id, email, role, created_at, updated_at)
SELECT
au.id,
au.email,
'admin' as role,
NOW() as created_at,
NOW() as updated_at
FROM auth.users au
WHERE au.email = 'michaelvx@gmail.com'
AND NOT EXISTS (
SELECT 1 FROM public.users pu WHERE pu.id = au.id
);
-- Option 2: If user exists, just update role to admin
UPDATE public.users
SET role = 'admin', updated_at = NOW()
WHERE email = 'michaelvx@gmail.com';
-- Verify the admin user was created/updated
SELECT id, email, role, created_at FROM users WHERE email = 'michaelvx@gmail.com';