-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake_admin_user.sql
More file actions
65 lines (58 loc) · 1.69 KB
/
Copy pathmake_admin_user.sql
File metadata and controls
65 lines (58 loc) · 1.69 KB
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
-- SQL Script to Make your admin email an Admin User
-- Run this in your Supabase SQL Editor
-- First, let's check if the user exists and get their ID
SELECT id, email, raw_user_meta_data
FROM auth.users
WHERE email = 'your-admin-email@gmail.com';
-- Update the user's profile to admin role
-- This will work if the user has already registered
UPDATE public.profiles
SET role = 'admin'
WHERE id = (
SELECT id
FROM auth.users
WHERE email = 'your-admin-email@gmail.com'
);Make kommidruthendra2005@gmail.com an Admin User
-- Run this in your Supabase SQL Editor
-- First, let's check if the user exists and get their ID
SELECT id, email, raw_user_meta_data
FROM auth.users
WHERE email = 'kommidruthendra2005@gmail.com';
-- Update the user's profile to admin role
-- This will work if the user has already registered
UPDATE public.profiles
SET role = 'admin'
WHERE id = (
SELECT id
FROM auth.users
WHERE email = 'kommidruthendra2005@gmail.com'
);
-- Alternative: If you need to create the profile first (in case it doesn't exist)
-- Uncomment the following lines if needed:
-- INSERT INTO public.profiles (
-- id,
-- username,
-- full_name,
-- role,
-- stories_count,
-- followers_count,
-- following_count,
-- subscription_status
-- )
-- SELECT
-- id,
-- COALESCE(raw_user_meta_data->>'username', 'admin_user'),
-- COALESCE(raw_user_meta_data->>'full_name', 'Admin User'),
-- 'admin',
-- 0,
-- 0,
-- 0,
-- 'premium'
-- FROM auth.users
-- WHERE email = 'kommidruthendra2005@gmail.com'
-- ON CONFLICT (id) DO UPDATE SET role = 'admin';
-- Verify the update worked
SELECT p.*, u.email
FROM public.profiles p
JOIN auth.users u ON p.id = u.id
WHERE u.email = 'kommidruthendra2005@gmail.com';