diff --git a/scripts/setup_first_admin.sql b/scripts/setup_first_admin.sql index f3dfcfa..34ad706 100644 --- a/scripts/setup_first_admin.sql +++ b/scripts/setup_first_admin.sql @@ -1,6 +1,13 @@ -- ============================================================ -- Script: crear primer usuario platform_admin -- +-- Verificado contra GoTrue v2.189.0 (supabase/gotrue:v2.189.0) +-- Schema de auth.users puede variar entre versiones de GoTrue. +-- Si falla con "column does not exist", verificar el schema real: +-- SELECT column_name FROM information_schema.columns +-- WHERE table_schema='auth' AND table_name='users' +-- ORDER BY ordinal_position; +-- -- USO: -- docker exec -i supabase-db psql -U postgres -d postgres \ -- -v email='admin@ejemplo.com' -v password='CAMBIAR' \ @@ -16,43 +23,23 @@ WITH new_user AS ( INSERT INTO auth.users ( - id, - instance_id, - aud, - role, - email, - encrypted_password, - confirmed_at, - created_at, - updated_at, - raw_app_meta_data, - raw_user_meta_data, - confirmation_token, - recovery_token, - email_change_token_new, - email_change, + id, instance_id, aud, role, email, encrypted_password, + email_confirmed_at, created_at, updated_at, + raw_app_meta_data, raw_user_meta_data, + confirmation_token, recovery_token, + email_change_token_new, email_change, is_super_admin ) VALUES ( gen_random_uuid(), '00000000-0000-0000-0000-000000000000', - 'authenticated', - 'authenticated', + 'authenticated', 'authenticated', :'email', extensions.crypt(:'password', extensions.gen_salt('bf')), - now(), - now(), - now(), + now(), now(), now(), '{"provider":"email","providers":["email"]}', - '{}', - '', - '', - '', - '', - false - ) - RETURNING id, email + '{}', '', '', '', '', false + ) RETURNING id ) INSERT INTO public.user_roles (user_id, app_role, org_id) SELECT id, 'platform_admin', '10000000-0000-0000-0000-000000000002' -FROM new_user -RETURNING (SELECT email FROM new_user), user_id; +FROM new_user;