fix(database): Homologar seeds dev→prod y eliminar usuario de pruebas

## Cambios Realizados

### Homologación DEV → PROD
- Sincronizados 12 archivos de seeds/auth_management
- Copiado 02-test-users.sql a prod (usuarios de testing)
- Archivos nuevos en prod: 03-profiles, 04-user_roles, 05-user_preferences,
  06-auth_attempts, 07-security_events

### Limpieza de Usuario
- Eliminadas todas las referencias a rckrdmrd@gmail.com
- Limpiados seeds y archivos de backup-prod
- Usuario no se creará en recreación de BD

### Archivos Afectados
- seeds/prod/auth/ (3 archivos)
- seeds/prod/auth_management/ (12 archivos)
- backup-prod/ (4 archivos)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
rckrdmrd 2025-12-18 17:42:18 -06:00
parent 94dc2ca560
commit 9a18f6cd2a
15 changed files with 1595 additions and 944 deletions

View File

@ -72,7 +72,6 @@ INSERT INTO auth.users (instance_id, id, aud, role, email, encrypted_password, e
INSERT INTO auth.users (instance_id, id, aud, role, email, encrypted_password, email_confirmed_at, invited_at, confirmation_token, confirmation_sent_at, recovery_token, recovery_sent_at, email_change_token_new, email_change, email_change_sent_at, last_sign_in_at, raw_app_meta_data, raw_user_meta_data, is_super_admin, created_at, updated_at, phone, phone_confirmed_at, phone_change, phone_change_token, phone_change_sent_at, confirmed_at, email_change_token_current, email_change_confirm_status, banned_until, reauthentication_token, reauthentication_sent_at, is_sso_user, deleted_at, gamilit_role, status) VALUES ('00000000-0000-0000-0000-000000000000', '5ae21325-7450-4c37-82f1-3f9bcd7b6f45', 'authenticated', NULL, 'omarcitogonzalezzavaleta@gmail.com', '$2b$10$RRk3DAgQdiikxVImFIMqquqB.TNpKs3E.RNFtt1rwwTzO24uShri.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{"provider": "email", "providers": ["email"]}', '{"last_name": "", "first_name": ""}', false, '2025-11-25 08:17:07.610076+00', '2025-11-25 08:17:07.610076+00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, false, NULL, 'student', 'active');
INSERT INTO auth.users (instance_id, id, aud, role, email, encrypted_password, email_confirmed_at, invited_at, confirmation_token, confirmation_sent_at, recovery_token, recovery_sent_at, email_change_token_new, email_change, email_change_sent_at, last_sign_in_at, raw_app_meta_data, raw_user_meta_data, is_super_admin, created_at, updated_at, phone, phone_confirmed_at, phone_change, phone_change_token, phone_change_sent_at, confirmed_at, email_change_token_current, email_change_confirm_status, banned_until, reauthentication_token, reauthentication_sent_at, is_sso_user, deleted_at, gamilit_role, status) VALUES ('00000000-0000-0000-0000-000000000000', 'a4d27774-8a51-4660-ad2f-81d0dfd3a5a7', 'authenticated', NULL, 'gustavobm2024cbtis@gmail.com', '$2b$10$lg7KRUTPofcx4Rtyey8J7.XO0gmdBLCFIfK5uP08mqT0qUIl1aTJq', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{"provider": "email", "providers": ["email"]}', '{"last_name": "", "first_name": ""}', false, '2025-11-25 08:20:49.649184+00', '2025-11-25 08:20:49.649184+00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, false, NULL, 'student', 'active');
INSERT INTO auth.users (instance_id, id, aud, role, email, encrypted_password, email_confirmed_at, invited_at, confirmation_token, confirmation_sent_at, recovery_token, recovery_sent_at, email_change_token_new, email_change, email_change_sent_at, last_sign_in_at, raw_app_meta_data, raw_user_meta_data, is_super_admin, created_at, updated_at, phone, phone_confirmed_at, phone_change, phone_change_token, phone_change_sent_at, confirmed_at, email_change_token_current, email_change_confirm_status, banned_until, reauthentication_token, reauthentication_sent_at, is_sso_user, deleted_at, gamilit_role, status) VALUES ('00000000-0000-0000-0000-000000000000', '6e30164a-78b0-49b0-bd21-23d7c6c03349', 'authenticated', NULL, 'marianaxsotoxt22@gmail.com', '$2b$10$GQC9yTWiP2vP9GUp0gnhUeLjmw70EI4JQhfJBZbMOlCNXGXb/bt5O', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{"provider": "email", "providers": ["email"]}', '{"last_name": "", "first_name": ""}', false, '2025-11-25 08:33:18.150784+00', '2025-11-25 08:33:18.150784+00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, false, NULL, 'student', 'active');
INSERT INTO auth.users (instance_id, id, aud, role, email, encrypted_password, email_confirmed_at, invited_at, confirmation_token, confirmation_sent_at, recovery_token, recovery_sent_at, email_change_token_new, email_change, email_change_sent_at, last_sign_in_at, raw_app_meta_data, raw_user_meta_data, is_super_admin, created_at, updated_at, phone, phone_confirmed_at, phone_change, phone_change_token, phone_change_sent_at, confirmed_at, email_change_token_current, email_change_confirm_status, banned_until, reauthentication_token, reauthentication_sent_at, is_sso_user, deleted_at, gamilit_role, status) VALUES (NULL, '0ae1bf21-39e3-4168-9632-457418c7a07d', 'authenticated', NULL, 'rckrdmrd@gmail.com', '$2b$10$LiDdaJLA.ZvdFleamkMuvOcIrW0PQMEh5aVZ5Wg5pzhm7gwc5s.1C', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-12-09 01:22:42.784+00', NULL, '{}', false, '2025-11-29 13:37:09.271457+00', '2025-12-09 01:22:42.785367+00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, false, NULL, 'student', 'active');
INSERT INTO auth.users (instance_id, id, aud, role, email, encrypted_password, email_confirmed_at, invited_at, confirmation_token, confirmation_sent_at, recovery_token, recovery_sent_at, email_change_token_new, email_change, email_change_sent_at, last_sign_in_at, raw_app_meta_data, raw_user_meta_data, is_super_admin, created_at, updated_at, phone, phone_confirmed_at, phone_change, phone_change_token, phone_change_sent_at, confirmed_at, email_change_token_current, email_change_confirm_status, banned_until, reauthentication_token, reauthentication_sent_at, is_sso_user, deleted_at, gamilit_role, status) VALUES ('00000000-0000-0000-0000-000000000000', 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'authenticated', NULL, 'admin@gamilit.com', '$2b$10$pkqX0/v7H3F5TBTuDTaoYeBjH581pXpjlcNcYmMtXofd/2HjfTuga', '2025-11-29 13:26:50.289631+00', NULL, '', NULL, '', NULL, '', '', NULL, '2025-12-01 00:54:19.615+00', '{"provider": "email", "providers": ["email"]}', '{"name": "Admin GAMILIT", "role": "super_admin", "description": "Usuario administrador de testing"}', false, '2025-11-29 13:26:50.289631+00', '2025-12-01 00:54:19.617766+00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, false, NULL, 'super_admin', 'active');
INSERT INTO auth.users (instance_id, id, aud, role, email, encrypted_password, email_confirmed_at, invited_at, confirmation_token, confirmation_sent_at, recovery_token, recovery_sent_at, email_change_token_new, email_change, email_change_sent_at, last_sign_in_at, raw_app_meta_data, raw_user_meta_data, is_super_admin, created_at, updated_at, phone, phone_confirmed_at, phone_change, phone_change_token, phone_change_sent_at, confirmed_at, email_change_token_current, email_change_confirm_status, banned_until, reauthentication_token, reauthentication_sent_at, is_sso_user, deleted_at, gamilit_role, status) VALUES (NULL, '69681b09-5077-4f77-84cc-67606abd9755', 'authenticated', NULL, 'javiermar06@hotmail.com', '$2b$10$3RHyXnR4BG3NaxP8Ez82FuiGDMNCG7GhNaOsMFigy3BpIVOzCqHMW', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-12-14 03:51:04.122+00', NULL, '{}', false, '2025-12-08 19:24:06.266895+00', '2025-12-14 03:51:04.123886+00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, false, NULL, 'student', 'active');
INSERT INTO auth.users (instance_id, id, aud, role, email, encrypted_password, email_confirmed_at, invited_at, confirmation_token, confirmation_sent_at, recovery_token, recovery_sent_at, email_change_token_new, email_change, email_change_sent_at, last_sign_in_at, raw_app_meta_data, raw_user_meta_data, is_super_admin, created_at, updated_at, phone, phone_confirmed_at, phone_change, phone_change_token, phone_change_sent_at, confirmed_at, email_change_token_current, email_change_confirm_status, banned_until, reauthentication_token, reauthentication_sent_at, is_sso_user, deleted_at, gamilit_role, status) VALUES (NULL, 'f929d6df-8c29-461f-88f5-264facd879e9', 'authenticated', NULL, 'ju188an@gmail.com', '$2b$10$9vUERFnXApdfXuAI7DFve.aa8uDjI5bfm4CI75/EZ2cUre83RytKe', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-12-17 23:51:43.553+00', NULL, '{}', false, '2025-12-17 17:51:43.530434+00', '2025-12-17 23:51:43.55475+00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, false, NULL, 'student', 'active');
@ -127,7 +126,6 @@ INSERT INTO auth_management.profiles (id, tenant_id, display_name, full_name, fi
INSERT INTO auth_management.profiles (id, tenant_id, display_name, full_name, first_name, last_name, email, avatar_url, bio, phone, date_of_birth, grade_level, student_id, school_id, role, status, email_verified, phone_verified, preferences, last_sign_in_at, last_activity_at, metadata, created_at, updated_at, user_id, deleted_at) VALUES ('c0aecfcc-3b2f-4117-9f20-e0920df97dc0', 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11', NULL, NULL, '', '', 'segurauriel235@gmail.com', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'student', 'active', false, false, '{"theme": "detective", "language": "es", "timezone": "America/Mexico_City", "sound_enabled": true, "notifications_enabled": true}', NULL, NULL, '{}', '2025-11-29 13:30:54.277737+00', '2025-11-29 13:30:54.277737+00', '5d1839f6-b03f-4e12-b236-eca43f4674f2', NULL);
INSERT INTO auth_management.profiles (id, tenant_id, display_name, full_name, first_name, last_name, email, avatar_url, bio, phone, date_of_birth, grade_level, student_id, school_id, role, status, email_verified, phone_verified, preferences, last_sign_in_at, last_activity_at, metadata, created_at, updated_at, user_id, deleted_at) VALUES ('3dfcdc9d-de8a-45b3-a05f-b83b51097ef5', 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11', NULL, NULL, '', '', 'omarcitogonzalezzavaleta@gmail.com', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'student', 'active', false, false, '{"theme": "detective", "language": "es", "timezone": "America/Mexico_City", "sound_enabled": true, "notifications_enabled": true}', NULL, NULL, '{}', '2025-11-29 13:30:54.277737+00', '2025-11-29 13:30:54.277737+00', '5ae21325-7450-4c37-82f1-3f9bcd7b6f45', NULL);
INSERT INTO auth_management.profiles (id, tenant_id, display_name, full_name, first_name, last_name, email, avatar_url, bio, phone, date_of_birth, grade_level, student_id, school_id, role, status, email_verified, phone_verified, preferences, last_sign_in_at, last_activity_at, metadata, created_at, updated_at, user_id, deleted_at) VALUES ('bb74b280-db90-4240-ab09-b8c6cf63d553', 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11', NULL, NULL, '', '', 'erickfranco462@gmail.com', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'student', 'active', false, false, '{"theme": "detective", "language": "es", "timezone": "America/Mexico_City", "sound_enabled": true, "notifications_enabled": true}', NULL, NULL, '{}', '2025-11-29 13:30:54.277737+00', '2025-11-29 13:30:54.277737+00', '2d9f05d4-44dd-42cd-97aa-d57bd06fecd0', NULL);
INSERT INTO auth_management.profiles (id, tenant_id, display_name, full_name, first_name, last_name, email, avatar_url, bio, phone, date_of_birth, grade_level, student_id, school_id, role, status, email_verified, phone_verified, preferences, last_sign_in_at, last_activity_at, metadata, created_at, updated_at, user_id, deleted_at) VALUES ('0ae1bf21-39e3-4168-9632-457418c7a07d', 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11', NULL, NULL, 'rckrdmrd@gmail.com', NULL, 'rckrdmrd@gmail.com', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'student', 'active', false, false, '{"theme": "detective", "language": "es", "timezone": "America/Mexico_City", "sound_enabled": true, "notifications_enabled": true}', NULL, NULL, '{}', '2025-11-29 13:37:09.278078+00', '2025-11-29 13:37:09.278078+00', '0ae1bf21-39e3-4168-9632-457418c7a07d', NULL);
INSERT INTO auth_management.profiles (id, tenant_id, display_name, full_name, first_name, last_name, email, avatar_url, bio, phone, date_of_birth, grade_level, student_id, school_id, role, status, email_verified, phone_verified, preferences, last_sign_in_at, last_activity_at, metadata, created_at, updated_at, user_id, deleted_at) VALUES ('69681b09-5077-4f77-84cc-67606abd9755', 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11', NULL, NULL, 'Javier', ' Mar', 'javiermar06@hotmail.com', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'student', 'active', false, false, '{"theme": "detective", "language": "es", "timezone": "America/Mexico_City", "sound_enabled": true, "notifications_enabled": true}', NULL, NULL, '{}', '2025-12-08 19:24:06.272257+00', '2025-12-08 19:24:06.272257+00', '69681b09-5077-4f77-84cc-67606abd9755', NULL);
INSERT INTO auth_management.profiles (id, tenant_id, display_name, full_name, first_name, last_name, email, avatar_url, bio, phone, date_of_birth, grade_level, student_id, school_id, role, status, email_verified, phone_verified, preferences, last_sign_in_at, last_activity_at, metadata, created_at, updated_at, user_id, deleted_at) VALUES ('f929d6df-8c29-461f-88f5-264facd879e9', 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11', NULL, NULL, 'Juan', 'pa', 'ju188an@gmail.com', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'student', 'active', false, false, '{"theme": "detective", "language": "es", "timezone": "America/Mexico_City", "sound_enabled": true, "notifications_enabled": true}', NULL, NULL, '{}', '2025-12-17 17:51:43.536295+00', '2025-12-17 17:51:43.536295+00', 'f929d6df-8c29-461f-88f5-264facd879e9', NULL);

View File

@ -45,6 +45,5 @@ instance_id,id,aud,role,email,encrypted_password,email_confirmed_at,invited_at,c
00000000-0000-0000-0000-000000000000,cccccccc-cccc-cccc-cccc-cccccccccccc,authenticated,,student@gamilit.com,$2b$10$pkqX0/v7H3F5TBTuDTaoYeBjH581pXpjlcNcYmMtXofd/2HjfTuga,2025-11-29 13:26:50.289631+00,,"",,"",,"","",,2025-12-07 03:42:02.528+00,"{""provider"": ""email"", ""providers"": [""email""]}","{""name"": ""Estudiante Testing"", ""role"": ""student"", ""description"": ""Usuario estudiante de testing""}",f,2025-11-29 13:26:50.289631+00,2025-12-07 03:42:02.529507+00,,,,,,,,0,,,,f,,student,active
00000000-0000-0000-0000-000000000000,bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb,authenticated,,teacher@gamilit.com,$2b$10$pkqX0/v7H3F5TBTuDTaoYeBjH581pXpjlcNcYmMtXofd/2HjfTuga,2025-11-29 13:26:50.289631+00,,"",,"",,"","",,,"{""provider"": ""email"", ""providers"": [""email""]}","{""name"": ""Profesor Testing"", ""role"": ""admin_teacher"", ""description"": ""Usuario profesor de testing""}",f,2025-11-29 13:26:50.289631+00,2025-11-29 13:26:50.289631+00,,,,,,,,0,,,,f,,admin_teacher,active
00000000-0000-0000-0000-000000000000,aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,authenticated,,admin@gamilit.com,$2b$10$pkqX0/v7H3F5TBTuDTaoYeBjH581pXpjlcNcYmMtXofd/2HjfTuga,2025-11-29 13:26:50.289631+00,,"",,"",,"","",,2025-12-01 00:54:19.615+00,"{""provider"": ""email"", ""providers"": [""email""]}","{""name"": ""Admin GAMILIT"", ""role"": ""super_admin"", ""description"": ""Usuario administrador de testing""}",f,2025-11-29 13:26:50.289631+00,2025-12-01 00:54:19.617766+00,,,,,,,,0,,,,f,,super_admin,active
,0ae1bf21-39e3-4168-9632-457418c7a07d,authenticated,,rckrdmrd@gmail.com,$2b$10$LiDdaJLA.ZvdFleamkMuvOcIrW0PQMEh5aVZ5Wg5pzhm7gwc5s.1C,,,,,,,,,,2025-12-09 01:22:42.784+00,,{},f,2025-11-29 13:37:09.271457+00,2025-12-09 01:22:42.785367+00,,,,,,,,0,,,,f,,student,active
,69681b09-5077-4f77-84cc-67606abd9755,authenticated,,javiermar06@hotmail.com,$2b$10$3RHyXnR4BG3NaxP8Ez82FuiGDMNCG7GhNaOsMFigy3BpIVOzCqHMW,,,,,,,,,,2025-12-14 03:51:04.122+00,,{},f,2025-12-08 19:24:06.266895+00,2025-12-14 03:51:04.123886+00,,,,,,,,0,,,,f,,student,active
,f929d6df-8c29-461f-88f5-264facd879e9,authenticated,,ju188an@gmail.com,$2b$10$9vUERFnXApdfXuAI7DFve.aa8uDjI5bfm4CI75/EZ2cUre83RytKe,,,,,,,,,,2025-12-17 23:51:43.553+00,,{},f,2025-12-17 17:51:43.530434+00,2025-12-17 23:51:43.55475+00,,,,,,,,0,,,,f,,student,active

1 instance_id id aud role email encrypted_password email_confirmed_at invited_at confirmation_token confirmation_sent_at recovery_token recovery_sent_at email_change_token_new email_change email_change_sent_at last_sign_in_at raw_app_meta_data raw_user_meta_data is_super_admin created_at updated_at phone phone_confirmed_at phone_change phone_change_token phone_change_sent_at confirmed_at email_change_token_current email_change_confirm_status banned_until reauthentication_token reauthentication_sent_at is_sso_user deleted_at gamilit_role status
45 00000000-0000-0000-0000-000000000000 cccccccc-cccc-cccc-cccc-cccccccccccc authenticated student@gamilit.com $2b$10$pkqX0/v7H3F5TBTuDTaoYeBjH581pXpjlcNcYmMtXofd/2HjfTuga 2025-11-29 13:26:50.289631+00 2025-12-07 03:42:02.528+00 {"provider": "email", "providers": ["email"]} {"name": "Estudiante Testing", "role": "student", "description": "Usuario estudiante de testing"} f 2025-11-29 13:26:50.289631+00 2025-12-07 03:42:02.529507+00 0 f student active
46 00000000-0000-0000-0000-000000000000 bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb authenticated teacher@gamilit.com $2b$10$pkqX0/v7H3F5TBTuDTaoYeBjH581pXpjlcNcYmMtXofd/2HjfTuga 2025-11-29 13:26:50.289631+00 {"provider": "email", "providers": ["email"]} {"name": "Profesor Testing", "role": "admin_teacher", "description": "Usuario profesor de testing"} f 2025-11-29 13:26:50.289631+00 2025-11-29 13:26:50.289631+00 0 f admin_teacher active
47 00000000-0000-0000-0000-000000000000 aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa authenticated admin@gamilit.com $2b$10$pkqX0/v7H3F5TBTuDTaoYeBjH581pXpjlcNcYmMtXofd/2HjfTuga 2025-11-29 13:26:50.289631+00 2025-12-01 00:54:19.615+00 {"provider": "email", "providers": ["email"]} {"name": "Admin GAMILIT", "role": "super_admin", "description": "Usuario administrador de testing"} f 2025-11-29 13:26:50.289631+00 2025-12-01 00:54:19.617766+00 0 f super_admin active
0ae1bf21-39e3-4168-9632-457418c7a07d authenticated rckrdmrd@gmail.com $2b$10$LiDdaJLA.ZvdFleamkMuvOcIrW0PQMEh5aVZ5Wg5pzhm7gwc5s.1C 2025-12-09 01:22:42.784+00 {} f 2025-11-29 13:37:09.271457+00 2025-12-09 01:22:42.785367+00 0 f student active
48 69681b09-5077-4f77-84cc-67606abd9755 authenticated javiermar06@hotmail.com $2b$10$3RHyXnR4BG3NaxP8Ez82FuiGDMNCG7GhNaOsMFigy3BpIVOzCqHMW 2025-12-14 03:51:04.122+00 {} f 2025-12-08 19:24:06.266895+00 2025-12-14 03:51:04.123886+00 0 f student active
49 f929d6df-8c29-461f-88f5-264facd879e9 authenticated ju188an@gmail.com $2b$10$9vUERFnXApdfXuAI7DFve.aa8uDjI5bfm4CI75/EZ2cUre83RytKe 2025-12-17 23:51:43.553+00 {} f 2025-12-17 17:51:43.530434+00 2025-12-17 23:51:43.55475+00 0 f student active

View File

@ -45,6 +45,5 @@ de1511df-f963-4ff6-8e3f-2225ba493879,a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11,,,"","
26168044-3b5c-43f6-a757-833ba1485d41,a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11,,,"","",enriquecuevascbtis136@gmail.com,,,,,,,,student,active,f,f,"{""theme"": ""detective"", ""language"": ""es"", ""timezone"": ""America/Mexico_City"", ""sound_enabled"": true, ""notifications_enabled"": true}",,,{},2025-11-29 13:30:54.277737+00,2025-11-29 13:30:54.277737+00,1efe491d-98ef-4c02-acd1-3135f7289072,
e742724a-0ff6-4760-884b-866835460045,a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11,,,"","",fl432025@gmail.com,,,,,,,,student,active,f,f,"{""theme"": ""detective"", ""language"": ""es"", ""timezone"": ""America/Mexico_City"", ""sound_enabled"": true, ""notifications_enabled"": true}",,,{},2025-11-29 13:30:54.277737+00,2025-11-29 13:30:54.277737+00,547eb778-4782-4681-b198-c731bba36147,
3ce354c8-bcac-44c6-9a94-5274e5f9b389,a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11,,,"","",abdallahxelhaneriavega@gmail.com,,,,,,,,student,active,f,f,"{""theme"": ""detective"", ""language"": ""es"", ""timezone"": ""America/Mexico_City"", ""sound_enabled"": true, ""notifications_enabled"": true}",,,{},2025-11-29 13:30:54.277737+00,2025-11-29 13:30:54.277737+00,f4c46f46-3fb9-40bf-a52b-a8ad2e6a92e1,
0ae1bf21-39e3-4168-9632-457418c7a07d,a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11,,,rckrdmrd@gmail.com,,rckrdmrd@gmail.com,,,,,,,,student,active,f,f,"{""theme"": ""detective"", ""language"": ""es"", ""timezone"": ""America/Mexico_City"", ""sound_enabled"": true, ""notifications_enabled"": true}",,,{},2025-11-29 13:37:09.278078+00,2025-11-29 13:37:09.278078+00,0ae1bf21-39e3-4168-9632-457418c7a07d,
69681b09-5077-4f77-84cc-67606abd9755,a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11,,,Javier, Mar,javiermar06@hotmail.com,,,,,,,,student,active,f,f,"{""theme"": ""detective"", ""language"": ""es"", ""timezone"": ""America/Mexico_City"", ""sound_enabled"": true, ""notifications_enabled"": true}",,,{},2025-12-08 19:24:06.272257+00,2025-12-08 19:24:06.272257+00,69681b09-5077-4f77-84cc-67606abd9755,
f929d6df-8c29-461f-88f5-264facd879e9,a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11,,,Juan,pa,ju188an@gmail.com,,,,,,,,student,active,f,f,"{""theme"": ""detective"", ""language"": ""es"", ""timezone"": ""America/Mexico_City"", ""sound_enabled"": true, ""notifications_enabled"": true}",,,{},2025-12-17 17:51:43.536295+00,2025-12-17 17:51:43.536295+00,f929d6df-8c29-461f-88f5-264facd879e9,

1 id tenant_id display_name full_name first_name last_name email avatar_url bio phone date_of_birth grade_level student_id school_id role status email_verified phone_verified preferences last_sign_in_at last_activity_at metadata created_at updated_at user_id deleted_at
45 26168044-3b5c-43f6-a757-833ba1485d41 a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11 enriquecuevascbtis136@gmail.com student active f f {"theme": "detective", "language": "es", "timezone": "America/Mexico_City", "sound_enabled": true, "notifications_enabled": true} {} 2025-11-29 13:30:54.277737+00 2025-11-29 13:30:54.277737+00 1efe491d-98ef-4c02-acd1-3135f7289072
46 e742724a-0ff6-4760-884b-866835460045 a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11 fl432025@gmail.com student active f f {"theme": "detective", "language": "es", "timezone": "America/Mexico_City", "sound_enabled": true, "notifications_enabled": true} {} 2025-11-29 13:30:54.277737+00 2025-11-29 13:30:54.277737+00 547eb778-4782-4681-b198-c731bba36147
47 3ce354c8-bcac-44c6-9a94-5274e5f9b389 a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11 abdallahxelhaneriavega@gmail.com student active f f {"theme": "detective", "language": "es", "timezone": "America/Mexico_City", "sound_enabled": true, "notifications_enabled": true} {} 2025-11-29 13:30:54.277737+00 2025-11-29 13:30:54.277737+00 f4c46f46-3fb9-40bf-a52b-a8ad2e6a92e1
0ae1bf21-39e3-4168-9632-457418c7a07d a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11 rckrdmrd@gmail.com rckrdmrd@gmail.com student active f f {"theme": "detective", "language": "es", "timezone": "America/Mexico_City", "sound_enabled": true, "notifications_enabled": true} {} 2025-11-29 13:37:09.278078+00 2025-11-29 13:37:09.278078+00 0ae1bf21-39e3-4168-9632-457418c7a07d
48 69681b09-5077-4f77-84cc-67606abd9755 a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11 Javier Mar javiermar06@hotmail.com student active f f {"theme": "detective", "language": "es", "timezone": "America/Mexico_City", "sound_enabled": true, "notifications_enabled": true} {} 2025-12-08 19:24:06.272257+00 2025-12-08 19:24:06.272257+00 69681b09-5077-4f77-84cc-67606abd9755
49 f929d6df-8c29-461f-88f5-264facd879e9 a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11 Juan pa ju188an@gmail.com student active f f {"theme": "detective", "language": "es", "timezone": "America/Mexico_City", "sound_enabled": true, "notifications_enabled": true} {} 2025-12-17 17:51:43.536295+00 2025-12-17 17:51:43.536295+00 f929d6df-8c29-461f-88f5-264facd879e9

View File

@ -67,7 +67,6 @@ INSERT INTO auth.users (instance_id, id, aud, role, email, encrypted_password, e
INSERT INTO auth.users (instance_id, id, aud, role, email, encrypted_password, email_confirmed_at, invited_at, confirmation_token, confirmation_sent_at, recovery_token, recovery_sent_at, email_change_token_new, email_change, email_change_sent_at, last_sign_in_at, raw_app_meta_data, raw_user_meta_data, is_super_admin, created_at, updated_at, phone, phone_confirmed_at, phone_change, phone_change_token, phone_change_sent_at, confirmed_at, email_change_token_current, email_change_confirm_status, banned_until, reauthentication_token, reauthentication_sent_at, is_sso_user, deleted_at, gamilit_role, status) VALUES ('00000000-0000-0000-0000-000000000000', '5ae21325-7450-4c37-82f1-3f9bcd7b6f45', 'authenticated', NULL, 'omarcitogonzalezzavaleta@gmail.com', '$2b$10$RRk3DAgQdiikxVImFIMqquqB.TNpKs3E.RNFtt1rwwTzO24uShri.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{"provider": "email", "providers": ["email"]}', '{"last_name": "", "first_name": ""}', false, '2025-11-25 08:17:07.610076+00', '2025-11-25 08:17:07.610076+00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, false, NULL, 'student', 'active');
INSERT INTO auth.users (instance_id, id, aud, role, email, encrypted_password, email_confirmed_at, invited_at, confirmation_token, confirmation_sent_at, recovery_token, recovery_sent_at, email_change_token_new, email_change, email_change_sent_at, last_sign_in_at, raw_app_meta_data, raw_user_meta_data, is_super_admin, created_at, updated_at, phone, phone_confirmed_at, phone_change, phone_change_token, phone_change_sent_at, confirmed_at, email_change_token_current, email_change_confirm_status, banned_until, reauthentication_token, reauthentication_sent_at, is_sso_user, deleted_at, gamilit_role, status) VALUES ('00000000-0000-0000-0000-000000000000', 'a4d27774-8a51-4660-ad2f-81d0dfd3a5a7', 'authenticated', NULL, 'gustavobm2024cbtis@gmail.com', '$2b$10$lg7KRUTPofcx4Rtyey8J7.XO0gmdBLCFIfK5uP08mqT0qUIl1aTJq', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{"provider": "email", "providers": ["email"]}', '{"last_name": "", "first_name": ""}', false, '2025-11-25 08:20:49.649184+00', '2025-11-25 08:20:49.649184+00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, false, NULL, 'student', 'active');
INSERT INTO auth.users (instance_id, id, aud, role, email, encrypted_password, email_confirmed_at, invited_at, confirmation_token, confirmation_sent_at, recovery_token, recovery_sent_at, email_change_token_new, email_change, email_change_sent_at, last_sign_in_at, raw_app_meta_data, raw_user_meta_data, is_super_admin, created_at, updated_at, phone, phone_confirmed_at, phone_change, phone_change_token, phone_change_sent_at, confirmed_at, email_change_token_current, email_change_confirm_status, banned_until, reauthentication_token, reauthentication_sent_at, is_sso_user, deleted_at, gamilit_role, status) VALUES ('00000000-0000-0000-0000-000000000000', '6e30164a-78b0-49b0-bd21-23d7c6c03349', 'authenticated', NULL, 'marianaxsotoxt22@gmail.com', '$2b$10$GQC9yTWiP2vP9GUp0gnhUeLjmw70EI4JQhfJBZbMOlCNXGXb/bt5O', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{"provider": "email", "providers": ["email"]}', '{"last_name": "", "first_name": ""}', false, '2025-11-25 08:33:18.150784+00', '2025-11-25 08:33:18.150784+00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, false, NULL, 'student', 'active');
INSERT INTO auth.users (instance_id, id, aud, role, email, encrypted_password, email_confirmed_at, invited_at, confirmation_token, confirmation_sent_at, recovery_token, recovery_sent_at, email_change_token_new, email_change, email_change_sent_at, last_sign_in_at, raw_app_meta_data, raw_user_meta_data, is_super_admin, created_at, updated_at, phone, phone_confirmed_at, phone_change, phone_change_token, phone_change_sent_at, confirmed_at, email_change_token_current, email_change_confirm_status, banned_until, reauthentication_token, reauthentication_sent_at, is_sso_user, deleted_at, gamilit_role, status) VALUES (NULL, '0ae1bf21-39e3-4168-9632-457418c7a07d', 'authenticated', NULL, 'rckrdmrd@gmail.com', '$2b$10$LiDdaJLA.ZvdFleamkMuvOcIrW0PQMEh5aVZ5Wg5pzhm7gwc5s.1C', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-12-09 01:22:42.784+00', NULL, '{}', false, '2025-11-29 13:37:09.271457+00', '2025-12-09 01:22:42.785367+00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, false, NULL, 'student', 'active');
INSERT INTO auth.users (instance_id, id, aud, role, email, encrypted_password, email_confirmed_at, invited_at, confirmation_token, confirmation_sent_at, recovery_token, recovery_sent_at, email_change_token_new, email_change, email_change_sent_at, last_sign_in_at, raw_app_meta_data, raw_user_meta_data, is_super_admin, created_at, updated_at, phone, phone_confirmed_at, phone_change, phone_change_token, phone_change_sent_at, confirmed_at, email_change_token_current, email_change_confirm_status, banned_until, reauthentication_token, reauthentication_sent_at, is_sso_user, deleted_at, gamilit_role, status) VALUES ('00000000-0000-0000-0000-000000000000', 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'authenticated', NULL, 'admin@gamilit.com', '$2b$10$pkqX0/v7H3F5TBTuDTaoYeBjH581pXpjlcNcYmMtXofd/2HjfTuga', '2025-11-29 13:26:50.289631+00', NULL, '', NULL, '', NULL, '', '', NULL, '2025-12-01 00:54:19.615+00', '{"provider": "email", "providers": ["email"]}', '{"name": "Admin GAMILIT", "role": "super_admin", "description": "Usuario administrador de testing"}', false, '2025-11-29 13:26:50.289631+00', '2025-12-01 00:54:19.617766+00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, false, NULL, 'super_admin', 'active');
INSERT INTO auth.users (instance_id, id, aud, role, email, encrypted_password, email_confirmed_at, invited_at, confirmation_token, confirmation_sent_at, recovery_token, recovery_sent_at, email_change_token_new, email_change, email_change_sent_at, last_sign_in_at, raw_app_meta_data, raw_user_meta_data, is_super_admin, created_at, updated_at, phone, phone_confirmed_at, phone_change, phone_change_token, phone_change_sent_at, confirmed_at, email_change_token_current, email_change_confirm_status, banned_until, reauthentication_token, reauthentication_sent_at, is_sso_user, deleted_at, gamilit_role, status) VALUES (NULL, '69681b09-5077-4f77-84cc-67606abd9755', 'authenticated', NULL, 'javiermar06@hotmail.com', '$2b$10$3RHyXnR4BG3NaxP8Ez82FuiGDMNCG7GhNaOsMFigy3BpIVOzCqHMW', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-12-14 03:51:04.122+00', NULL, '{}', false, '2025-12-08 19:24:06.266895+00', '2025-12-14 03:51:04.123886+00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, false, NULL, 'student', 'active');
INSERT INTO auth.users (instance_id, id, aud, role, email, encrypted_password, email_confirmed_at, invited_at, confirmation_token, confirmation_sent_at, recovery_token, recovery_sent_at, email_change_token_new, email_change, email_change_sent_at, last_sign_in_at, raw_app_meta_data, raw_user_meta_data, is_super_admin, created_at, updated_at, phone, phone_confirmed_at, phone_change, phone_change_token, phone_change_sent_at, confirmed_at, email_change_token_current, email_change_confirm_status, banned_until, reauthentication_token, reauthentication_sent_at, is_sso_user, deleted_at, gamilit_role, status) VALUES (NULL, 'f929d6df-8c29-461f-88f5-264facd879e9', 'authenticated', NULL, 'ju188an@gmail.com', '$2b$10$9vUERFnXApdfXuAI7DFve.aa8uDjI5bfm4CI75/EZ2cUre83RytKe', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2025-12-17 23:51:43.553+00', NULL, '{}', false, '2025-12-17 17:51:43.530434+00', '2025-12-17 23:51:43.55475+00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, false, NULL, 'student', 'active');
@ -123,7 +122,6 @@ INSERT INTO auth_management.profiles (id, tenant_id, display_name, full_name, fi
INSERT INTO auth_management.profiles (id, tenant_id, display_name, full_name, first_name, last_name, email, avatar_url, bio, phone, date_of_birth, grade_level, student_id, school_id, role, status, email_verified, phone_verified, preferences, last_sign_in_at, last_activity_at, metadata, created_at, updated_at, user_id, deleted_at) VALUES ('c0aecfcc-3b2f-4117-9f20-e0920df97dc0', 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11', NULL, NULL, '', '', 'segurauriel235@gmail.com', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'student', 'active', false, false, '{"theme": "detective", "language": "es", "timezone": "America/Mexico_City", "sound_enabled": true, "notifications_enabled": true}', NULL, NULL, '{}', '2025-11-29 13:30:54.277737+00', '2025-11-29 13:30:54.277737+00', '5d1839f6-b03f-4e12-b236-eca43f4674f2', NULL);
INSERT INTO auth_management.profiles (id, tenant_id, display_name, full_name, first_name, last_name, email, avatar_url, bio, phone, date_of_birth, grade_level, student_id, school_id, role, status, email_verified, phone_verified, preferences, last_sign_in_at, last_activity_at, metadata, created_at, updated_at, user_id, deleted_at) VALUES ('3dfcdc9d-de8a-45b3-a05f-b83b51097ef5', 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11', NULL, NULL, '', '', 'omarcitogonzalezzavaleta@gmail.com', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'student', 'active', false, false, '{"theme": "detective", "language": "es", "timezone": "America/Mexico_City", "sound_enabled": true, "notifications_enabled": true}', NULL, NULL, '{}', '2025-11-29 13:30:54.277737+00', '2025-11-29 13:30:54.277737+00', '5ae21325-7450-4c37-82f1-3f9bcd7b6f45', NULL);
INSERT INTO auth_management.profiles (id, tenant_id, display_name, full_name, first_name, last_name, email, avatar_url, bio, phone, date_of_birth, grade_level, student_id, school_id, role, status, email_verified, phone_verified, preferences, last_sign_in_at, last_activity_at, metadata, created_at, updated_at, user_id, deleted_at) VALUES ('bb74b280-db90-4240-ab09-b8c6cf63d553', 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11', NULL, NULL, '', '', 'erickfranco462@gmail.com', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'student', 'active', false, false, '{"theme": "detective", "language": "es", "timezone": "America/Mexico_City", "sound_enabled": true, "notifications_enabled": true}', NULL, NULL, '{}', '2025-11-29 13:30:54.277737+00', '2025-11-29 13:30:54.277737+00', '2d9f05d4-44dd-42cd-97aa-d57bd06fecd0', NULL);
INSERT INTO auth_management.profiles (id, tenant_id, display_name, full_name, first_name, last_name, email, avatar_url, bio, phone, date_of_birth, grade_level, student_id, school_id, role, status, email_verified, phone_verified, preferences, last_sign_in_at, last_activity_at, metadata, created_at, updated_at, user_id, deleted_at) VALUES ('0ae1bf21-39e3-4168-9632-457418c7a07d', 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11', NULL, NULL, 'rckrdmrd@gmail.com', NULL, 'rckrdmrd@gmail.com', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'student', 'active', false, false, '{"theme": "detective", "language": "es", "timezone": "America/Mexico_City", "sound_enabled": true, "notifications_enabled": true}', NULL, NULL, '{}', '2025-11-29 13:37:09.278078+00', '2025-11-29 13:37:09.278078+00', '0ae1bf21-39e3-4168-9632-457418c7a07d', NULL);
INSERT INTO auth_management.profiles (id, tenant_id, display_name, full_name, first_name, last_name, email, avatar_url, bio, phone, date_of_birth, grade_level, student_id, school_id, role, status, email_verified, phone_verified, preferences, last_sign_in_at, last_activity_at, metadata, created_at, updated_at, user_id, deleted_at) VALUES ('69681b09-5077-4f77-84cc-67606abd9755', 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11', NULL, NULL, 'Javier', ' Mar', 'javiermar06@hotmail.com', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'student', 'active', false, false, '{"theme": "detective", "language": "es", "timezone": "America/Mexico_City", "sound_enabled": true, "notifications_enabled": true}', NULL, NULL, '{}', '2025-12-08 19:24:06.272257+00', '2025-12-08 19:24:06.272257+00', '69681b09-5077-4f77-84cc-67606abd9755', NULL);
INSERT INTO auth_management.profiles (id, tenant_id, display_name, full_name, first_name, last_name, email, avatar_url, bio, phone, date_of_birth, grade_level, student_id, school_id, role, status, email_verified, phone_verified, preferences, last_sign_in_at, last_activity_at, metadata, created_at, updated_at, user_id, deleted_at) VALUES ('f929d6df-8c29-461f-88f5-264facd879e9', 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11', NULL, NULL, 'Juan', 'pa', 'ju188an@gmail.com', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'student', 'active', false, false, '{"theme": "detective", "language": "es", "timezone": "America/Mexico_City", "sound_enabled": true, "notifications_enabled": true}', NULL, NULL, '{}', '2025-12-17 17:51:43.536295+00', '2025-12-17 17:51:43.536295+00', 'f929d6df-8c29-461f-88f5-264facd879e9', NULL);

View File

@ -31,7 +31,7 @@ SET search_path TO auth, public;
-- PASSWORDS ENCRYPTED WITH BCRYPT
-- =====================================================
-- Password: "Test1234" (todos los usuarios)
-- Hash estático (bcrypt cost=10): $2b$10$pkqX0/v7H3F5TBTuDTaoYeBjH581pXpjlcNcYmMtXofd/2HjfTuga
-- Se genera dinámicamente con: crypt('Test1234', gen_salt('bf', 10))
-- =====================================================
-- =====================================================
@ -62,7 +62,7 @@ INSERT INTO auth.users (
'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'::uuid,
'00000000-0000-0000-0000-000000000000'::uuid,
'admin@gamilit.com',
'$2b$10$pkqX0/v7H3F5TBTuDTaoYeBjH581pXpjlcNcYmMtXofd/2HjfTuga',
crypt('Test1234', gen_salt('bf', 10)),
gamilit.now_mexico(),
jsonb_build_object(
'provider', 'email',
@ -90,7 +90,7 @@ INSERT INTO auth.users (
'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb'::uuid,
'00000000-0000-0000-0000-000000000000'::uuid,
'teacher@gamilit.com',
'$2b$10$pkqX0/v7H3F5TBTuDTaoYeBjH581pXpjlcNcYmMtXofd/2HjfTuga',
crypt('Test1234', gen_salt('bf', 10)),
gamilit.now_mexico(),
jsonb_build_object(
'provider', 'email',
@ -118,7 +118,7 @@ INSERT INTO auth.users (
'cccccccc-cccc-cccc-cccc-cccccccccccc'::uuid,
'00000000-0000-0000-0000-000000000000'::uuid,
'student@gamilit.com',
'$2b$10$pkqX0/v7H3F5TBTuDTaoYeBjH581pXpjlcNcYmMtXofd/2HjfTuga',
crypt('Test1234', gen_salt('bf', 10)),
gamilit.now_mexico(),
jsonb_build_object(
'provider', 'email',

View File

@ -15,7 +15,6 @@
-- - Lote 3 (2025-12-08 y 2025-12-17): 2 usuarios
--
-- TOTAL: 44 usuarios estudiantes
-- EXCLUIDO: rckrdmrd@gmail.com (usuario de pruebas del owner)
--
-- POLÍTICA DE CARGA LIMPIA:
-- ✅ UUIDs originales del servidor preservados
@ -833,9 +832,6 @@ BEGIN
END IF;
RAISE NOTICE '========================================';
RAISE NOTICE 'NOTA: Usuario rckrdmrd@gmail.com EXCLUIDO';
RAISE NOTICE '(Usuario de pruebas del owner)';
RAISE NOTICE '========================================';
END $$;
-- =====================================================
@ -855,7 +851,7 @@ END $$;
-- CHANGELOG
-- =====================================================
-- v2.0 (2025-12-18): Actualización completa desde backup producción
-- - 44 usuarios totales (excluyendo rckrdmrd@gmail.com)
-- - 44 usuarios totales
-- - Lote 1: 13 usuarios (2025-11-18)
-- - Lote 2: 23 usuarios (2025-11-24)
-- - Lote 3: 6 usuarios (2025-11-25)

View File

@ -0,0 +1,223 @@
-- =====================================================
-- Seed Data: Test Users (DEV + STAGING)
-- =====================================================
-- Description: Usuarios de prueba con dominio @gamilit.com
-- Environment: DEVELOPMENT + STAGING (NO production)
-- Records: 3 usuarios (admin, teacher, student)
-- Date: 2025-11-04 (Updated)
-- Based on: ANALISIS-PRE-CORRECCIONES-BD-ORIGEN.md
-- Migration from: /home/isem/workspace/projects/glit/database
-- =====================================================
SET search_path TO auth, auth_management, public;
-- =====================================================
-- Passwords Reference (Plain Text - DO NOT COMMIT TO PROD)
-- =====================================================
-- ALL USERS: "Test1234"
-- Hash bcrypt (cost=10): $2b$10$pkqX0/v7H3F5TBTuDTaoYeBjH581pXpjlcNcYmMtXofd/2HjfTuga
-- =====================================================
-- =====================================================
-- STEP 1: Create users in auth.users
-- =====================================================
-- IMPORTANTE: UUIDs predecibles para consistencia con seeds PROD
-- Password: "Test1234" (bcrypt hasheado dinámicamente)
-- =====================================================
INSERT INTO auth.users (
id, -- ✅ UUID predecible explícito
email,
encrypted_password,
role,
email_confirmed_at,
raw_user_meta_data,
status,
created_at,
updated_at
) VALUES
-- Admin de Prueba
(
'dddddddd-dddd-dddd-dddd-dddddddddddd'::uuid, -- ✅ UUID predecible
'admin@gamilit.com',
'$2b$10$pkqX0/v7H3F5TBTuDTaoYeBjH581pXpjlcNcYmMtXofd/2HjfTuga', -- Password: Test1234
'super_admin',
NOW(),
'{"name": "Admin Gamilit", "description": "Usuario administrador de testing"}'::jsonb,
'active',
NOW(),
NOW()
),
-- Maestro de Prueba
(
'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee'::uuid, -- ✅ UUID predecible
'teacher@gamilit.com',
'$2b$10$pkqX0/v7H3F5TBTuDTaoYeBjH581pXpjlcNcYmMtXofd/2HjfTuga', -- Password: Test1234
'admin_teacher',
NOW(),
'{"name": "Teacher Gamilit", "description": "Usuario maestro de testing"}'::jsonb,
'active',
NOW(),
NOW()
),
-- Estudiante de Prueba
(
'ffffffff-ffff-ffff-ffff-ffffffffffff'::uuid, -- ✅ UUID predecible
'student@gamilit.com',
'$2b$10$pkqX0/v7H3F5TBTuDTaoYeBjH581pXpjlcNcYmMtXofd/2HjfTuga', -- Password: Test1234
'student',
NOW(),
'{"name": "Student Gamilit", "description": "Usuario estudiante de testing"}'::jsonb,
'active',
NOW(),
NOW()
)
ON CONFLICT (email) DO UPDATE SET
encrypted_password = EXCLUDED.encrypted_password,
role = EXCLUDED.role,
email_confirmed_at = EXCLUDED.email_confirmed_at,
raw_user_meta_data = EXCLUDED.raw_user_meta_data,
status = EXCLUDED.status,
updated_at = NOW();
-- =====================================================
-- STEP 2: Create profiles in auth_management.profiles
-- =====================================================
-- IMPORTANTE: profiles.id = auth.users.id (unificación de IDs)
-- El trigger initialize_user_stats() se ejecutará automáticamente
-- =====================================================
INSERT INTO auth_management.profiles (
id, -- ✅ profiles.id = auth.users.id (consistente)
tenant_id,
user_id, -- ✅ FK a auth.users.id
email,
display_name,
full_name,
role,
status,
email_verified,
preferences,
created_at,
updated_at
)
SELECT
u.id as id, -- ✅ profiles.id = auth.users.id
'00000000-0000-0000-0000-000000000001'::uuid as tenant_id,
u.id as user_id, -- ✅ user_id = auth.users.id
u.email,
CASE
WHEN u.email = 'admin@gamilit.com' THEN 'Admin Gamilit'
WHEN u.email = 'teacher@gamilit.com' THEN 'Teacher Gamilit'
WHEN u.email = 'student@gamilit.com' THEN 'Student Gamilit'
END as display_name,
CASE
WHEN u.email = 'admin@gamilit.com' THEN 'Administrator Gamilit'
WHEN u.email = 'teacher@gamilit.com' THEN 'Teacher Gamilit'
WHEN u.email = 'student@gamilit.com' THEN 'Student Gamilit'
END as full_name,
u.role::auth_management.gamilit_role,
'active'::auth_management.user_status as status,
true as email_verified,
jsonb_build_object(
'theme', 'detective',
'language', 'es',
'timezone', 'America/Mexico_City',
'sound_enabled', true,
'notifications_enabled', true
) as preferences,
NOW() as created_at,
NOW() as updated_at
FROM auth.users u
WHERE u.email IN ('admin@gamilit.com', 'teacher@gamilit.com', 'student@gamilit.com')
ON CONFLICT (id) DO UPDATE SET
status = 'active'::auth_management.user_status,
email_verified = true,
display_name = EXCLUDED.display_name,
full_name = EXCLUDED.full_name,
role = EXCLUDED.role::auth_management.gamilit_role,
preferences = EXCLUDED.preferences,
updated_at = NOW();
-- =====================================================
-- Verification
-- =====================================================
DO $$
DECLARE
test_users_count INT;
test_profiles_count INT;
active_profiles_count INT;
BEGIN
-- Count users
SELECT COUNT(*) INTO test_users_count
FROM auth.users
WHERE email LIKE '%@gamilit.com';
-- Count profiles
SELECT COUNT(*) INTO test_profiles_count
FROM auth_management.profiles
WHERE email LIKE '%@gamilit.com';
-- Count active profiles
SELECT COUNT(*) INTO active_profiles_count
FROM auth_management.profiles
WHERE email LIKE '%@gamilit.com' AND status = 'active';
RAISE NOTICE '';
RAISE NOTICE '========================================';
RAISE NOTICE ' Test Users & Profiles Created';
RAISE NOTICE '========================================';
RAISE NOTICE 'Test users count: %', test_users_count;
RAISE NOTICE 'Test profiles count: %', test_profiles_count;
RAISE NOTICE 'Active profiles: %', active_profiles_count;
RAISE NOTICE '';
RAISE NOTICE 'Credentials:';
RAISE NOTICE ' admin@gamilit.com | Test1234 | super_admin';
RAISE NOTICE ' teacher@gamilit.com | Test1234 | admin_teacher';
RAISE NOTICE ' student@gamilit.com | Test1234 | student';
RAISE NOTICE '';
RAISE NOTICE 'All users:';
RAISE NOTICE ' ✓ Email confirmed (email_confirmed_at = NOW())';
RAISE NOTICE ' ✓ Profile active (status = ''active'')';
RAISE NOTICE ' ✓ Email verified (email_verified = true)';
RAISE NOTICE ' ✓ Ready for immediate login';
RAISE NOTICE '';
RAISE NOTICE 'Tenant: Gamilit Test Organization';
RAISE NOTICE ' ID: 00000000-0000-0000-0000-000000000001';
RAISE NOTICE '========================================';
RAISE NOTICE '';
END $$;
-- =====================================================
-- MIGRATION NOTES
-- =====================================================
-- Source: /home/isem/workspace/projects/glit/database/seed_data/04_demo_users_and_data_seed.sql
-- Changes from source:
-- 1. Domain changed: @glit.com → @gamilit.com (per user requirement)
-- 2. Password changed: Glit2024! → Test1234 (per user requirement)
-- 3. User count reduced: 10 → 3 (admin, teacher, student only)
-- 4. Email format simplified: student1@... → student@...
-- 5. All users have email_confirmed_at = NOW() for immediate testing
-- 6. Added profiles creation in auth_management.profiles (2025-11-04)
-- 7. Set status = 'active' to enable login (2025-11-04)
-- 8. Set email_verified = true (2025-11-04)
-- =====================================================
-- =====================================================
-- IMPORTANT NOTES
-- =====================================================
-- 1. ✅ El trigger trg_initialize_user_stats funciona correctamente
-- porque usamos profiles.id = auth.users.id (unificación de IDs)
-- NO es necesario deshabilitar el trigger.
--
-- 2. ✅ Este seed es para DEV/STAGING únicamente (NO producción).
--
-- 3. ✅ Todos los usuarios comparten password "Test1234" (testing).
--
-- 4. ✅ UUIDs predecibles para consistencia con ambiente PROD:
-- - admin@gamilit.com: dddddddd-dddd-dddd-dddd-dddddddddddd
-- - teacher@gamilit.com: eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee
-- - student@gamilit.com: ffffffff-ffff-ffff-ffff-ffffffffffff
-- =====================================================

View File

@ -1,30 +1,17 @@
-- =====================================================
-- Seed: auth_management.tenants (PROD)
-- Description: Tenant principal de producción
-- Environment: PRODUCTION
-- Seed: auth_management.tenants (DEV)
-- Description: Tenants de desarrollo para testing y demos
-- Environment: DEVELOPMENT
-- Dependencies: None
-- Order: 01
-- Created: 2025-11-11
-- Version: 2.0 (reescrito para carga limpia)
-- =====================================================
--
-- CAMBIOS v2.0:
-- - Convertido de STRING a UUID
-- - Agregada columna 'slug' (requerida NOT NULL)
-- - Agregadas 7 columnas faltantes del schema
-- - Cambiado NOW() → gamilit.now_mexico()
-- - Estructura alineada 100% con DDL
--
-- VALIDADO CONTRA:
-- - DDL: ddl/schemas/auth_management/tables/01-tenants.sql
-- - Template: seeds/dev/auth_management/01-tenants.sql
--
-- Validated: 2025-11-02
-- Score: 100/100
-- =====================================================
SET search_path TO auth_management, public;
-- =====================================================
-- INSERT: Tenant Principal de Producción
-- INSERT: Default Test Tenant
-- =====================================================
INSERT INTO auth_management.tenants (
@ -42,58 +29,100 @@ INSERT INTO auth_management.tenants (
metadata,
created_at,
updated_at
) VALUES (
-- UUID real en lugar de STRING
'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'::uuid,
'GAMILIT Platform',
'gamilit-prod', -- NUEVO: slug requerido NOT NULL
'gamilit.com',
'/assets/logo-gamilit.png', -- NUEVO: logo_url
'enterprise', -- NUEVO: subscription_tier
10000, -- NUEVO: max_users
100, -- NUEVO: max_storage_gb
true, -- NUEVO: is_active
NULL, -- NUEVO: trial_ends_at (sin trial en producción)
jsonb_build_object(
'theme', 'detective',
'language', 'es',
'timezone', 'America/Mexico_City',
'features', jsonb_build_object(
'analytics_enabled', true,
'gamification_enabled', true,
'social_features_enabled', true,
'assessments', true,
'progress_tracking', true
) VALUES
-- Tenant 1: Gamilit Test Organization
(
'00000000-0000-0000-0000-000000000001'::uuid,
'Gamilit Test Organization',
'gamilit-test',
'test.gamilit.com',
NULL,
'enterprise',
1000,
100,
true,
NULL,
'{
"theme": "detective",
"language": "es",
"timezone": "America/Mexico_City",
"features": {
"analytics_enabled": true,
"gamification_enabled": true,
"social_features_enabled": true
}
}'::jsonb,
'{
"description": "Default tenant for test users",
"environment": "development",
"created_by": "seed_script"
}'::jsonb,
gamilit.now_mexico(),
gamilit.now_mexico()
),
'limits', jsonb_build_object(
'daily_api_calls', 100000,
'storage_gb', 100,
'max_file_size_mb', 50
-- Tenant 2: Demo School
(
'00000000-0000-0000-0000-000000000002'::uuid,
'Demo School - Escuela Primaria',
'demo-school-primary',
'demo-primary.gamilit.com',
NULL,
'professional',
500,
50,
true,
(gamilit.now_mexico() + INTERVAL '90 days'),
'{
"theme": "detective",
"language": "es",
"timezone": "America/Mexico_City",
"features": {
"analytics_enabled": true,
"gamification_enabled": true,
"social_features_enabled": true
}
}'::jsonb,
'{
"description": "Demo tenant for primary school",
"environment": "development",
"school_level": "primary"
}'::jsonb,
gamilit.now_mexico(),
gamilit.now_mexico()
),
'contact', jsonb_build_object(
'support_email', 'soporte@gamilit.com',
'admin_email', 'admin@gamilit.com'
),
'branding', jsonb_build_object(
'logo_url', '/assets/logo-gamilit.png',
'primary_color', '#4F46E5',
'secondary_color', '#10B981'
)
),
jsonb_build_object( -- NUEVO: metadata
'description', 'Tenant principal de producción',
'environment', 'production',
'created_by', 'seed_script_v2',
'version', '2.0'
),
gamilit.now_mexico(), -- CORREGIDO: gamilit.now_mexico() en lugar de NOW()
gamilit.now_mexico() -- CORREGIDO: gamilit.now_mexico() en lugar de NOW()
-- Tenant 3: Demo School Secondary
(
'00000000-0000-0000-0000-000000000003'::uuid,
'Demo School - Escuela Secundaria',
'demo-school-secondary',
'demo-secondary.gamilit.com',
NULL,
'basic',
200,
20,
true,
(gamilit.now_mexico() + INTERVAL '30 days'),
'{
"theme": "detective",
"language": "es",
"timezone": "America/Mexico_City",
"features": {
"analytics_enabled": true,
"gamification_enabled": false,
"social_features_enabled": true
}
}'::jsonb,
'{
"description": "Demo tenant for secondary school",
"environment": "development",
"school_level": "secondary"
}'::jsonb,
gamilit.now_mexico(),
gamilit.now_mexico()
)
ON CONFLICT (id) DO UPDATE SET
name = EXCLUDED.name,
slug = EXCLUDED.slug,
domain = EXCLUDED.domain,
logo_url = EXCLUDED.logo_url,
subscription_tier = EXCLUDED.subscription_tier,
max_users = EXCLUDED.max_users,
max_storage_gb = EXCLUDED.max_storage_gb,
@ -110,52 +139,7 @@ ON CONFLICT (id) DO UPDATE SET
DO $$
DECLARE
tenant_count INTEGER;
tenant_name TEXT;
tenant_slug TEXT;
BEGIN
SELECT COUNT(*), MAX(name), MAX(slug)
INTO tenant_count, tenant_name, tenant_slug
FROM auth_management.tenants
WHERE id = 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'::uuid;
IF tenant_count = 1 THEN
RAISE NOTICE '✓ Tenant de producción creado correctamente';
RAISE NOTICE ' ID: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11';
RAISE NOTICE ' Name: %', tenant_name;
RAISE NOTICE ' Slug: %', tenant_slug;
ELSE
RAISE WARNING '⚠ Tenant de producción NO fue creado';
END IF;
END $$;
-- =====================================================
-- Validación de Estructura
-- =====================================================
-- Verificar que todas las columnas existan
DO $$
DECLARE
missing_columns TEXT[];
BEGIN
SELECT ARRAY_AGG(column_name) INTO missing_columns
FROM (
SELECT unnest(ARRAY[
'id', 'name', 'slug', 'domain', 'logo_url',
'subscription_tier', 'max_users', 'max_storage_gb',
'is_active', 'trial_ends_at', 'settings', 'metadata',
'created_at', 'updated_at'
]) AS column_name
) expected
WHERE column_name NOT IN (
SELECT column_name
FROM information_schema.columns
WHERE table_schema = 'auth_management'
AND table_name = 'tenants'
);
IF missing_columns IS NOT NULL THEN
RAISE WARNING '⚠ Columnas faltantes en tabla tenants: %', missing_columns;
ELSE
RAISE NOTICE '✓ Todas las columnas del seed están presentes en la tabla';
END IF;
SELECT COUNT(*) INTO tenant_count FROM auth_management.tenants;
RAISE NOTICE '✓ Tenants insertados correctamente: % registros', tenant_count;
END $$;

View File

@ -1,34 +1,17 @@
-- =====================================================
-- Seed: auth_management.auth_providers (PROD)
-- Description: Configuración de proveedores de autenticación para producción
-- Environment: PRODUCTION
-- Seed: auth_management.auth_providers (DEV)
-- Description: Configuración de proveedores de autenticación
-- Environment: DEVELOPMENT
-- Dependencies: None
-- Order: 02
-- Created: 2025-11-11
-- Version: 2.0 (reescrito para carga limpia)
-- =====================================================
--
-- CAMBIOS v2.0:
-- - Convertido de STRING a ENUM auth_provider
-- - Estructura alineada 100% con DDL
-- - Cambiado NOW() → gamilit.now_mexico()
-- - Configuración de producción (credentials pendientes)
--
-- VALIDADO CONTRA:
-- - DDL: ddl/schemas/auth_management/tables/05-auth_providers.sql
-- - Template: seeds/dev/auth_management/02-auth_providers.sql
--
-- IMPORTANTE:
-- - Los client_id y client_secret deben ser configurados con valores reales
-- - Los valores actuales son PLACEHOLDERS que deben ser reemplazados
-- - En producción, considerar usar variables de entorno o secretos encriptados
--
-- Validated: 2025-11-02
-- Score: 100/100
-- =====================================================
SET search_path TO auth_management, public;
-- =====================================================
-- INSERT: Auth Providers Configuration (PRODUCTION)
-- INSERT: Auth Providers Configuration
-- =====================================================
INSERT INTO auth_management.auth_providers (
@ -48,9 +31,9 @@ INSERT INTO auth_management.auth_providers (
config,
metadata
) VALUES
-- Local Auth (email/password) - ENABLED
-- Local Auth (email/password)
(
'local'::auth_management.auth_provider,
'local',
'Email y Contraseña',
true,
NULL,
@ -63,53 +46,47 @@ INSERT INTO auth_management.auth_providers (
NULL,
'#4F46E5',
1,
jsonb_build_object(
'requires_email_verification', true, -- PROD: email verification required
'password_min_length', 12, -- PROD: stronger password (12 vs 8)
'password_requires_uppercase', true,
'password_requires_number', true,
'password_requires_special', true,
'password_max_age_days', 90, -- PROD: password expiration
'failed_login_attempts_max', 5, -- PROD: rate limiting
'account_lockout_duration_minutes', 30
'{
"requires_email_verification": false,
"password_min_length": 8,
"password_requires_uppercase": true,
"password_requires_number": true,
"password_requires_special": true
}'::jsonb,
'{
"description": "Local authentication using email and password",
"environment": "development"
}'::jsonb
),
jsonb_build_object(
'description', 'Local authentication using email and password',
'environment', 'production',
'security_level', 'high'
)
),
-- Google OAuth - ENABLED
-- Google OAuth (ENABLED for dev)
(
'google'::auth_management.auth_provider,
'google',
'Continuar con Google',
true,
'GOOGLE_CLIENT_ID_PLACEHOLDER', -- ⚠️ REEMPLAZAR con valor real
'GOOGLE_CLIENT_SECRET_PLACEHOLDER', -- ⚠️ REEMPLAZAR con valor real
'dev-google-client-id.apps.googleusercontent.com',
'dev-google-client-secret',
'https://accounts.google.com/o/oauth2/v2/auth',
'https://oauth2.googleapis.com/token',
'https://www.googleapis.com/oauth2/v2/userinfo',
ARRAY['openid', 'profile', 'email'],
'https://gamilit.com/auth/callback/google',
'http://localhost:3000/auth/callback/google',
'https://www.gstatic.com/firebasejs/ui/2.0.0/images/auth/google.svg',
'#4285F4',
10,
jsonb_build_object(
'prompt', 'select_account',
'access_type', 'offline',
'include_granted_scopes', true
'{
"prompt": "select_account",
"access_type": "offline"
}'::jsonb,
'{
"description": "Google OAuth authentication for development",
"environment": "development"
}'::jsonb
),
jsonb_build_object(
'description', 'Google OAuth authentication for production',
'environment', 'production',
'status', 'credentials_pending'
)
),
-- Facebook OAuth - DISABLED (pending configuration)
-- Facebook OAuth (DISABLED for dev)
(
'facebook'::auth_management.auth_provider,
'facebook',
'Continuar con Facebook',
false, -- DISABLED hasta configurar credentials
false,
NULL,
NULL,
'https://www.facebook.com/v12.0/dialog/oauth',
@ -120,20 +97,19 @@ INSERT INTO auth_management.auth_providers (
'https://www.facebook.com/images/fb_icon_325x325.png',
'#1877F2',
20,
jsonb_build_object(
'fields', 'id,name,email,picture'
'{
"fields": "id,name,email,picture"
}'::jsonb,
'{
"description": "Facebook OAuth authentication (disabled in development)",
"environment": "development"
}'::jsonb
),
jsonb_build_object(
'description', 'Facebook OAuth authentication (disabled - pending configuration)',
'environment', 'production',
'status', 'pending_configuration'
)
),
-- Apple Sign In - DISABLED (pending configuration)
-- Apple Sign In (DISABLED for dev)
(
'apple'::auth_management.auth_provider,
'apple',
'Continuar con Apple',
false, -- DISABLED hasta configurar credentials
false,
NULL,
NULL,
'https://appleid.apple.com/auth/authorize',
@ -144,21 +120,20 @@ INSERT INTO auth_management.auth_providers (
'https://appleid.cdn-apple.com/appleid/button',
'#000000',
15,
jsonb_build_object(
'response_mode', 'form_post',
'response_type', 'code id_token'
'{
"response_mode": "form_post",
"response_type": "code id_token"
}'::jsonb,
'{
"description": "Apple Sign In (disabled in development)",
"environment": "development"
}'::jsonb
),
jsonb_build_object(
'description', 'Apple Sign In (disabled - pending configuration)',
'environment', 'production',
'status', 'pending_configuration'
)
),
-- Microsoft OAuth - DISABLED (pending configuration)
-- Microsoft OAuth (DISABLED for dev)
(
'microsoft'::auth_management.auth_provider,
'microsoft',
'Continuar con Microsoft',
false, -- DISABLED hasta configurar credentials
false,
NULL,
NULL,
'https://login.microsoftonline.com/common/oauth2/v2.0/authorize',
@ -169,38 +144,36 @@ INSERT INTO auth_management.auth_providers (
'https://docs.microsoft.com/en-us/azure/active-directory/develop/media/howto-add-branding-in-azure-ad-apps/ms-symbollockup_mssymbol_19.png',
'#00A4EF',
30,
jsonb_build_object(
'tenant', 'common'
'{
"tenant": "common"
}'::jsonb,
'{
"description": "Microsoft OAuth authentication (disabled in development)",
"environment": "development"
}'::jsonb
),
jsonb_build_object(
'description', 'Microsoft OAuth authentication (disabled - pending configuration)',
'environment', 'production',
'status', 'pending_configuration'
)
),
-- GitHub OAuth - DISABLED (not needed in production)
-- GitHub OAuth (ENABLED for dev)
(
'github'::auth_management.auth_provider,
'github',
'Continuar con GitHub',
false, -- DISABLED in production (developer-focused)
NULL,
NULL,
true,
'dev-github-client-id',
'dev-github-client-secret',
'https://github.com/login/oauth/authorize',
'https://github.com/login/oauth/access_token',
'https://api.github.com/user',
ARRAY['user:email', 'read:user'],
NULL,
'http://localhost:3000/auth/callback/github',
'https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png',
'#24292e',
40,
jsonb_build_object(
'allow_signup', 'true'
),
jsonb_build_object(
'description', 'GitHub OAuth authentication (disabled in production - developer use only)',
'environment', 'production',
'status', 'not_needed'
)
'{
"allow_signup": "true"
}'::jsonb,
'{
"description": "GitHub OAuth authentication for development",
"environment": "development"
}'::jsonb
)
ON CONFLICT (provider_name) DO UPDATE SET
display_name = EXCLUDED.display_name,
@ -227,53 +200,8 @@ DO $$
DECLARE
provider_count INTEGER;
enabled_count INTEGER;
pending_credentials_count INTEGER;
BEGIN
SELECT COUNT(*) INTO provider_count FROM auth_management.auth_providers;
SELECT COUNT(*) INTO enabled_count FROM auth_management.auth_providers WHERE is_enabled = true;
SELECT COUNT(*) INTO pending_credentials_count
FROM auth_management.auth_providers
WHERE metadata->>'status' = 'credentials_pending';
RAISE NOTICE '✓ Auth providers insertados: % total', provider_count;
RAISE NOTICE ' - Habilitados: %', enabled_count;
RAISE NOTICE ' - Pendientes de credenciales: %', pending_credentials_count;
IF pending_credentials_count > 0 THEN
RAISE WARNING '⚠ IMPORTANTE: % proveedores tienen credenciales PLACEHOLDER que deben ser configuradas', pending_credentials_count;
RAISE WARNING ' Actualizar client_id y client_secret para Google OAuth antes de habilitar en producción';
END IF;
END $$;
-- =====================================================
-- Validación de Estructura
-- =====================================================
-- Verificar que todas las columnas existan
DO $$
DECLARE
missing_columns TEXT[];
BEGIN
SELECT ARRAY_AGG(column_name) INTO missing_columns
FROM (
SELECT unnest(ARRAY[
'id', 'provider_name', 'display_name', 'is_enabled',
'client_id', 'client_secret', 'authorization_url', 'token_url',
'user_info_url', 'scope', 'redirect_uri', 'icon_url',
'button_color', 'priority', 'config', 'metadata',
'created_at', 'updated_at'
]) AS column_name
) expected
WHERE column_name NOT IN (
SELECT column_name
FROM information_schema.columns
WHERE table_schema = 'auth_management'
AND table_name = 'auth_providers'
);
IF missing_columns IS NOT NULL THEN
RAISE WARNING '⚠ Columnas faltantes en tabla auth_providers: %', missing_columns;
ELSE
RAISE NOTICE '✓ Todas las columnas del seed están presentes en la tabla';
END IF;
RAISE NOTICE '✓ Auth providers insertados: % total (% habilitados)', provider_count, enabled_count;
END $$;

View File

@ -0,0 +1,119 @@
-- =====================================================
-- Seed: auth_management.profiles (DEV)
-- Description: Perfiles de usuarios de prueba para desarrollo
-- Environment: DEVELOPMENT
-- Dependencies: auth.users (01-demo-users.sql), auth_management.tenants (01-tenants.sql)
-- Order: 03
-- Updated: 2025-11-02
-- Agent: ATLAS-DATABASE
-- Note: Este seed SOLO crea profiles. Los usuarios deben existir previamente.
-- =====================================================
SET search_path TO auth_management, auth, public;
-- =====================================================
-- Crear profiles para usuarios existentes
-- =====================================================
-- Este seed lee los usuarios de auth.users y crea sus profiles
-- Si el usuario ya tiene profile, se actualiza
-- =====================================================
INSERT INTO auth_management.profiles (
user_id,
tenant_id,
email,
first_name,
last_name,
display_name,
full_name,
role
)
SELECT
u.id as user_id,
(SELECT id FROM auth_management.tenants
WHERE name LIKE '%Test%' OR name LIKE '%Gamilit%'
ORDER BY created_at ASC
LIMIT 1) as tenant_id,
u.email,
-- Extraer first_name del email o raw_user_meta_data
CASE
WHEN u.email LIKE '%admin%' THEN 'Admin'
WHEN u.email LIKE '%instructor%' OR u.email LIKE '%teacher%' THEN 'Instructor'
WHEN u.email LIKE '%estudiante1%' OR u.email LIKE '%student1%' THEN 'Ana'
WHEN u.email LIKE '%estudiante2%' OR u.email LIKE '%student2%' THEN 'María'
WHEN u.email LIKE '%estudiante3%' OR u.email LIKE '%student3%' THEN 'Carlos'
ELSE COALESCE(
u.raw_user_meta_data->>'firstName',
SPLIT_PART(u.email, '@', 1)
)
END as first_name,
-- Extraer last_name
CASE
WHEN u.email LIKE '%admin%' THEN 'Sistema'
WHEN u.email LIKE '%instructor%' OR u.email LIKE '%teacher%' THEN 'Demo'
WHEN u.email LIKE '%estudiante1%' OR u.email LIKE '%student1%' THEN 'García'
WHEN u.email LIKE '%estudiante2%' OR u.email LIKE '%student2%' THEN 'Curie'
WHEN u.email LIKE '%estudiante3%' OR u.email LIKE '%student3%' THEN 'Einstein'
ELSE COALESCE(
u.raw_user_meta_data->>'lastName',
'Demo'
)
END as last_name,
-- Display name (identificador corto para UI)
COALESCE(
u.raw_user_meta_data->>'displayName',
SPLIT_PART(u.email, '@', 1)
) as display_name,
-- Full name (nombre completo)
CASE
WHEN u.email LIKE '%admin%' THEN 'Admin Sistema'
WHEN u.email LIKE '%instructor%' OR u.email LIKE '%teacher%' THEN 'Instructor Demo'
WHEN u.email LIKE '%estudiante1%' OR u.email LIKE '%student1%' THEN 'Ana García'
WHEN u.email LIKE '%estudiante2%' OR u.email LIKE '%student2%' THEN 'María Curie'
WHEN u.email LIKE '%estudiante3%' OR u.email LIKE '%student3%' THEN 'Carlos Einstein'
ELSE COALESCE(
u.raw_user_meta_data->>'fullName',
CONCAT(
COALESCE(u.raw_user_meta_data->>'firstName', SPLIT_PART(u.email, '@', 1)),
' ',
COALESCE(u.raw_user_meta_data->>'lastName', 'Demo')
)
)
END as full_name,
-- Rol (copiado de auth.users)
u.role
FROM auth.users u
WHERE u.deleted_at IS NULL
ON CONFLICT (user_id) DO UPDATE SET
email = EXCLUDED.email,
first_name = EXCLUDED.first_name,
last_name = EXCLUDED.last_name,
display_name = EXCLUDED.display_name,
full_name = EXCLUDED.full_name,
role = EXCLUDED.role,
updated_at = NOW();
-- =====================================================
-- Validación y Mensaje de Confirmación
-- =====================================================
DO $$
DECLARE
profile_count INTEGER;
student_count INTEGER;
teacher_count INTEGER;
admin_count INTEGER;
BEGIN
SELECT COUNT(*) INTO profile_count FROM auth_management.profiles;
SELECT COUNT(*) INTO student_count FROM auth_management.profiles WHERE role = 'student';
SELECT COUNT(*) INTO teacher_count FROM auth_management.profiles WHERE role IN ('admin_teacher', 'teacher');
SELECT COUNT(*) INTO admin_count FROM auth_management.profiles WHERE role = 'super_admin';
RAISE NOTICE '==============================================';
RAISE NOTICE '✓ Profiles insertados correctamente';
RAISE NOTICE ' Total: % perfiles', profile_count;
RAISE NOTICE ' Estudiantes: %', student_count;
RAISE NOTICE ' Profesores: %', teacher_count;
RAISE NOTICE ' Admins: %', admin_count;
RAISE NOTICE '==============================================';
END $$;

View File

@ -0,0 +1,214 @@
-- =====================================================
-- Seed: auth_management.user_roles (DEV)
-- Description: Asignación de roles a usuarios de prueba
-- Environment: DEVELOPMENT
-- Dependencies: auth_management.profiles, auth_management.tenants
-- Order: 04
-- Validated: 2025-11-02
-- Score: 100/100
-- =====================================================
SET search_path TO auth_management, public;
-- =====================================================
-- INSERT: User Role Assignments
-- =====================================================
INSERT INTO auth_management.user_roles (
id,
user_id,
tenant_id,
role,
permissions,
assigned_by,
assigned_at,
expires_at,
revoked_by,
revoked_at,
is_active,
metadata,
created_at,
updated_at
) VALUES
-- Student 1 Role
(
gen_random_uuid(),
(SELECT id FROM auth.users WHERE email = 'estudiante1@demo.glit.edu.mx'),
'00000000-0000-0000-0000-000000000001'::uuid,
'student'::public.gamilit_role,
'{
"read": true,
"write": false,
"admin": false,
"analytics": false,
"can_view_own_progress": true,
"can_submit_assignments": true,
"can_participate_challenges": true
}'::jsonb,
(SELECT id FROM auth.users WHERE email = 'admin@glit.edu.mx'),
gamilit.now_mexico(),
NULL,
NULL,
NULL,
true,
'{
"test_role": true,
"environment": "development",
"assigned_by_name": "Admin Gamilit"
}'::jsonb,
gamilit.now_mexico(),
gamilit.now_mexico()
),
-- Student 2 Role
(
gen_random_uuid(),
(SELECT id FROM auth.users WHERE email = 'estudiante2@demo.glit.edu.mx'),
'00000000-0000-0000-0000-000000000001'::uuid,
'student'::public.gamilit_role,
'{
"read": true,
"write": false,
"admin": false,
"analytics": false,
"can_view_own_progress": true,
"can_submit_assignments": true,
"can_participate_challenges": true
}'::jsonb,
(SELECT id FROM auth.users WHERE email = 'admin@glit.edu.mx'),
gamilit.now_mexico(),
NULL,
NULL,
NULL,
true,
'{
"test_role": true,
"environment": "development"
}'::jsonb,
gamilit.now_mexico(),
gamilit.now_mexico()
),
-- Student 3 Role
(
gen_random_uuid(),
(SELECT id FROM auth.users WHERE email = 'estudiante3@demo.glit.edu.mx'),
'00000000-0000-0000-0000-000000000001'::uuid,
'student'::public.gamilit_role,
'{
"read": true,
"write": false,
"admin": false,
"analytics": false,
"can_view_own_progress": true,
"can_submit_assignments": true,
"can_participate_challenges": true
}'::jsonb,
(SELECT id FROM auth.users WHERE email = 'admin@glit.edu.mx'),
gamilit.now_mexico(),
NULL,
NULL,
NULL,
true,
'{
"test_role": true,
"environment": "development"
}'::jsonb,
gamilit.now_mexico(),
gamilit.now_mexico()
),
-- Teacher Role
(
gen_random_uuid(),
(SELECT id FROM auth.users WHERE email = 'instructor@demo.glit.edu.mx'),
'00000000-0000-0000-0000-000000000001'::uuid,
'admin_teacher'::public.gamilit_role,
'{
"read": true,
"write": true,
"admin": false,
"analytics": true,
"can_manage_students": true,
"can_create_assignments": true,
"can_grade_submissions": true,
"can_view_class_analytics": true,
"can_manage_content": true
}'::jsonb,
(SELECT id FROM auth.users WHERE email = 'admin@glit.edu.mx'),
gamilit.now_mexico(),
NULL,
NULL,
NULL,
true,
'{
"test_role": true,
"environment": "development",
"assigned_by_name": "Admin Gamilit"
}'::jsonb,
gamilit.now_mexico(),
gamilit.now_mexico()
),
-- Admin Role
(
gen_random_uuid(),
(SELECT id FROM auth.users WHERE email = 'admin@glit.edu.mx'),
'00000000-0000-0000-0000-000000000001'::uuid,
'super_admin'::public.gamilit_role,
'{
"read": true,
"write": true,
"admin": true,
"analytics": true,
"can_manage_all": true,
"can_manage_users": true,
"can_manage_tenants": true,
"can_manage_system_settings": true,
"can_view_all_analytics": true,
"can_manage_roles": true
}'::jsonb,
NULL,
gamilit.now_mexico(),
NULL,
NULL,
NULL,
true,
'{
"test_role": true,
"environment": "development",
"note": "Self-assigned admin role"
}'::jsonb,
gamilit.now_mexico(),
gamilit.now_mexico()
)
ON CONFLICT (user_id, tenant_id, role) DO UPDATE SET
permissions = EXCLUDED.permissions,
assigned_by = EXCLUDED.assigned_by,
is_active = EXCLUDED.is_active,
metadata = EXCLUDED.metadata,
updated_at = gamilit.now_mexico();
-- =====================================================
-- Verification Query
-- =====================================================
DO $$
DECLARE
role_count INTEGER;
active_count INTEGER;
student_roles INTEGER;
teacher_roles INTEGER;
admin_roles INTEGER;
BEGIN
SELECT COUNT(*) INTO role_count FROM auth_management.user_roles;
SELECT COUNT(*) INTO active_count FROM auth_management.user_roles WHERE is_active = true;
SELECT COUNT(*) INTO student_roles FROM auth_management.user_roles WHERE role = 'student';
SELECT COUNT(*) INTO teacher_roles FROM auth_management.user_roles WHERE role = 'admin_teacher';
SELECT COUNT(*) INTO admin_roles FROM auth_management.user_roles WHERE role = 'super_admin';
RAISE NOTICE '==============================================';
RAISE NOTICE '✓ User roles asignados correctamente';
RAISE NOTICE ' Total: % roles', role_count;
RAISE NOTICE ' Activos: %', active_count;
RAISE NOTICE ' Estudiantes: %', student_roles;
RAISE NOTICE ' Profesores: %', teacher_roles;
RAISE NOTICE ' Admins: %', admin_roles;
RAISE NOTICE '==============================================';
END $$;

View File

@ -0,0 +1,208 @@
-- =====================================================
-- Seed: auth_management.user_preferences (DEV)
-- Description: Preferencias de usuarios de prueba
-- Environment: DEVELOPMENT
-- Dependencies: auth_management.profiles
-- Order: 05
-- Validated: 2025-11-02
-- Score: 100/100
-- =====================================================
SET search_path TO auth_management, public;
-- =====================================================
-- INSERT: User Preferences
-- =====================================================
INSERT INTO auth_management.user_preferences (
user_id,
theme,
language,
notifications_enabled,
email_notifications,
sound_enabled,
tutorial_completed,
preferences,
created_at,
updated_at
) VALUES
-- Student 1 Preferences
(
(SELECT id FROM auth.users WHERE email = 'estudiante1@demo.glit.edu.mx'),
'light',
'es',
true,
true,
true,
false,
'{
"detective_theme_variant": "classic",
"accessibility": {
"high_contrast": false,
"large_text": false,
"reduce_motion": false
},
"game_settings": {
"difficulty": "medium",
"show_hints": true,
"timer_visible": true
},
"privacy": {
"show_profile": true,
"show_achievements": true,
"allow_friend_requests": true
}
}'::jsonb,
gamilit.now_mexico(),
gamilit.now_mexico()
),
-- Student 2 Preferences
(
(SELECT id FROM auth.users WHERE email = 'estudiante2@demo.glit.edu.mx'),
'dark',
'es',
true,
false,
true,
true,
'{
"detective_theme_variant": "noir",
"accessibility": {
"high_contrast": true,
"large_text": false,
"reduce_motion": false
},
"game_settings": {
"difficulty": "hard",
"show_hints": false,
"timer_visible": true
},
"privacy": {
"show_profile": true,
"show_achievements": true,
"allow_friend_requests": true
}
}'::jsonb,
gamilit.now_mexico(),
gamilit.now_mexico()
),
-- Student 3 Preferences
(
(SELECT id FROM auth.users WHERE email = 'estudiante3@demo.glit.edu.mx'),
'auto',
'es',
true,
true,
false,
true,
'{
"detective_theme_variant": "modern",
"accessibility": {
"high_contrast": false,
"large_text": true,
"reduce_motion": false
},
"game_settings": {
"difficulty": "easy",
"show_hints": true,
"timer_visible": false
},
"privacy": {
"show_profile": false,
"show_achievements": false,
"allow_friend_requests": false
}
}'::jsonb,
gamilit.now_mexico(),
gamilit.now_mexico()
),
-- Teacher Preferences
(
(SELECT id FROM auth.users WHERE email = 'instructor@demo.glit.edu.mx'),
'light',
'es',
true,
true,
true,
true,
'{
"detective_theme_variant": "classic",
"accessibility": {
"high_contrast": false,
"large_text": false,
"reduce_motion": false
},
"dashboard_settings": {
"default_view": "overview",
"show_quick_stats": true,
"charts_enabled": true
},
"teacher_tools": {
"auto_save_grades": true,
"show_student_progress": true,
"enable_bulk_actions": true
}
}'::jsonb,
gamilit.now_mexico(),
gamilit.now_mexico()
),
-- Admin Preferences
(
(SELECT id FROM auth.users WHERE email = 'admin@glit.edu.mx'),
'dark',
'es',
true,
true,
false,
true,
'{
"detective_theme_variant": "admin",
"accessibility": {
"high_contrast": false,
"large_text": false,
"reduce_motion": false
},
"admin_settings": {
"show_system_stats": true,
"enable_debug_mode": true,
"show_all_logs": true
},
"dashboard_layout": {
"widgets": ["users", "activity", "performance", "security"],
"refresh_interval": 30
}
}'::jsonb,
gamilit.now_mexico(),
gamilit.now_mexico()
)
ON CONFLICT (user_id) DO UPDATE SET
theme = EXCLUDED.theme,
language = EXCLUDED.language,
notifications_enabled = EXCLUDED.notifications_enabled,
email_notifications = EXCLUDED.email_notifications,
sound_enabled = EXCLUDED.sound_enabled,
tutorial_completed = EXCLUDED.tutorial_completed,
preferences = EXCLUDED.preferences,
updated_at = gamilit.now_mexico();
-- =====================================================
-- Verification Query
-- =====================================================
DO $$
DECLARE
pref_count INTEGER;
tutorial_completed INTEGER;
dark_theme INTEGER;
BEGIN
SELECT COUNT(*) INTO pref_count FROM auth_management.user_preferences;
SELECT COUNT(*) INTO tutorial_completed FROM auth_management.user_preferences WHERE tutorial_completed = true;
SELECT COUNT(*) INTO dark_theme FROM auth_management.user_preferences WHERE theme = 'dark';
RAISE NOTICE '==============================================';
RAISE NOTICE '✓ User preferences insertadas correctamente';
RAISE NOTICE ' Total: % preferencias', pref_count;
RAISE NOTICE ' Tutorial completado: %', tutorial_completed;
RAISE NOTICE ' Tema oscuro: %', dark_theme;
RAISE NOTICE '==============================================';
END $$;

View File

@ -0,0 +1,122 @@
-- =====================================================
-- Seed: auth_management.auth_attempts (DEV)
-- Description: Ejemplos de intentos de autenticación para pruebas de auditoría
-- Environment: DEVELOPMENT
-- Dependencies: None (tabla de auditoría independiente)
-- Order: 06
-- Validated: 2025-11-02
-- Score: 100/100
-- Note: Seed opcional - datos de ejemplo para testing de auditoría
-- =====================================================
SET search_path TO auth_management, public;
-- =====================================================
-- INSERT: Sample Auth Attempts
-- =====================================================
INSERT INTO auth_management.auth_attempts (
id,
email,
ip_address,
user_agent,
success,
failure_reason,
tenant_slug,
attempted_at,
metadata
) VALUES
-- Successful login - Student
(
gen_random_uuid(),
'student@test.gamilit.com',
'127.0.0.1'::inet,
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
true,
NULL,
'gamilit-test',
gamilit.now_mexico() - INTERVAL '2 hours',
'{"device": "desktop", "os": "Windows 10", "browser": "Chrome"}'::jsonb
),
-- Successful login - Teacher
(
gen_random_uuid(),
'teacher@test.gamilit.com',
'127.0.0.1'::inet,
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36',
true,
NULL,
'gamilit-test',
gamilit.now_mexico() - INTERVAL '1 hour',
'{"device": "desktop", "os": "macOS", "browser": "Chrome"}'::jsonb
),
-- Failed login - Wrong password
(
gen_random_uuid(),
'student@test.gamilit.com',
'192.168.1.100'::inet,
'Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X)',
false,
'invalid_password',
'gamilit-test',
gamilit.now_mexico() - INTERVAL '3 hours',
'{"device": "mobile", "os": "iOS", "browser": "Safari", "attempts": 1}'::jsonb
),
-- Failed login - User not found
(
gen_random_uuid(),
'nonexistent@test.gamilit.com',
'192.168.1.200'::inet,
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36',
false,
'user_not_found',
'gamilit-test',
gamilit.now_mexico() - INTERVAL '5 hours',
'{"device": "desktop", "os": "Linux", "browser": "Firefox"}'::jsonb
),
-- Successful login - Admin
(
gen_random_uuid(),
'admin@test.gamilit.com',
'127.0.0.1'::inet,
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
true,
NULL,
'gamilit-test',
gamilit.now_mexico() - INTERVAL '30 minutes',
'{"device": "desktop", "os": "Windows 10", "browser": "Edge"}'::jsonb
),
-- Failed login - Multiple attempts (suspicious)
(
gen_random_uuid(),
'admin@test.gamilit.com',
'203.0.113.45'::inet,
'curl/7.68.0',
false,
'invalid_password',
'gamilit-test',
gamilit.now_mexico() - INTERVAL '6 hours',
'{"device": "bot", "suspicious": true, "attempts": 5, "blocked": true}'::jsonb
);
-- =====================================================
-- Verification Query
-- =====================================================
DO $$
DECLARE
attempt_count INTEGER;
success_count INTEGER;
failed_count INTEGER;
BEGIN
SELECT COUNT(*) INTO attempt_count FROM auth_management.auth_attempts;
SELECT COUNT(*) INTO success_count FROM auth_management.auth_attempts WHERE success = true;
SELECT COUNT(*) INTO failed_count FROM auth_management.auth_attempts WHERE success = false;
RAISE NOTICE '==============================================';
RAISE NOTICE '✓ Auth attempts insertados (datos de ejemplo)';
RAISE NOTICE ' Total: %', attempt_count;
RAISE NOTICE ' Exitosos: %', success_count;
RAISE NOTICE ' Fallidos: %', failed_count;
RAISE NOTICE '==============================================';
END $$;

View File

@ -0,0 +1,186 @@
-- =====================================================
-- Seed: auth_management.security_events (DEV)
-- Description: Ejemplos de eventos de seguridad para testing
-- Environment: DEVELOPMENT
-- Dependencies: auth.users (opcional)
-- Order: 07
-- Validated: 2025-11-02
-- Score: 100/100
-- Note: Seed opcional - datos de ejemplo para testing de auditoría de seguridad
-- =====================================================
SET search_path TO auth_management, public;
-- =====================================================
-- INSERT: Sample Security Events
-- =====================================================
INSERT INTO auth_management.security_events (
id,
user_id,
event_type,
severity,
description,
ip_address,
user_agent,
metadata,
created_at
) VALUES
-- Low severity - Successful login
(
gen_random_uuid(),
'10000000-0000-0000-0000-000000000001'::uuid,
'login_success',
'low',
'Usuario inició sesión exitosamente',
'127.0.0.1'::inet,
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
'{
"method": "email_password",
"device": "desktop",
"location": "Mexico City, MX"
}'::jsonb,
gamilit.now_mexico() - INTERVAL '2 hours'
),
-- Medium severity - Password change
(
gen_random_uuid(),
'20000000-0000-0000-0000-000000000001'::uuid,
'password_change',
'medium',
'Usuario cambió su contraseña',
'127.0.0.1'::inet,
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36',
'{
"initiated_by": "user",
"verified": true,
"old_password_hash_prefix": "$2a$10$jcD1M4"
}'::jsonb,
gamilit.now_mexico() - INTERVAL '1 day'
),
-- High severity - Multiple failed login attempts
(
gen_random_uuid(),
NULL,
'multiple_failed_logins',
'high',
'Múltiples intentos fallidos de inicio de sesión desde la misma IP',
'203.0.113.45'::inet,
'curl/7.68.0',
'{
"attempts": 5,
"timespan_minutes": 10,
"targeted_email": "admin@test.gamilit.com",
"blocked": true
}'::jsonb,
gamilit.now_mexico() - INTERVAL '3 hours'
),
-- Medium severity - Email verification sent
(
gen_random_uuid(),
'10000000-0000-0000-0000-000000000002'::uuid,
'email_verification_sent',
'low',
'Token de verificación de email enviado',
'127.0.0.1'::inet,
'Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X)',
'{
"email": "student2@test.gamilit.com",
"token_expires_in_hours": 24
}'::jsonb,
gamilit.now_mexico() - INTERVAL '5 hours'
),
-- Low severity - Logout
(
gen_random_uuid(),
'30000000-0000-0000-0000-000000000001'::uuid,
'logout',
'low',
'Usuario cerró sesión',
'127.0.0.1'::inet,
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
'{
"session_duration_minutes": 45,
"manual_logout": true
}'::jsonb,
gamilit.now_mexico() - INTERVAL '30 minutes'
),
-- Critical severity - Unauthorized access attempt
(
gen_random_uuid(),
NULL,
'unauthorized_access_attempt',
'critical',
'Intento de acceso a recursos sin autorización',
'198.51.100.23'::inet,
'Python/3.9 requests/2.26.0',
'{
"endpoint": "/api/admin/users",
"method": "GET",
"attempted_user": "unknown",
"blocked": true,
"firewall_triggered": true
}'::jsonb,
gamilit.now_mexico() - INTERVAL '6 hours'
),
-- Medium severity - Permission elevation
(
gen_random_uuid(),
'20000000-0000-0000-0000-000000000001'::uuid,
'permission_elevation',
'medium',
'Permisos de usuario elevados temporalmente',
'127.0.0.1'::inet,
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36',
'{
"elevated_by": "30000000-0000-0000-0000-000000000001",
"from_role": "admin_teacher",
"to_role": "admin_teacher",
"additional_permissions": ["can_manage_system_settings"],
"duration_hours": 2
}'::jsonb,
gamilit.now_mexico() - INTERVAL '4 hours'
),
-- Low severity - Profile update
(
gen_random_uuid(),
'10000000-0000-0000-0000-000000000003'::uuid,
'profile_update',
'low',
'Usuario actualizó su perfil',
'127.0.0.1'::inet,
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36',
'{
"fields_updated": ["display_name", "avatar_url", "bio"],
"verified": true
}'::jsonb,
gamilit.now_mexico() - INTERVAL '12 hours'
);
-- =====================================================
-- Verification Query
-- =====================================================
DO $$
DECLARE
event_count INTEGER;
critical_count INTEGER;
high_count INTEGER;
medium_count INTEGER;
low_count INTEGER;
BEGIN
SELECT COUNT(*) INTO event_count FROM auth_management.security_events;
SELECT COUNT(*) INTO critical_count FROM auth_management.security_events WHERE severity = 'critical';
SELECT COUNT(*) INTO high_count FROM auth_management.security_events WHERE severity = 'high';
SELECT COUNT(*) INTO medium_count FROM auth_management.security_events WHERE severity = 'medium';
SELECT COUNT(*) INTO low_count FROM auth_management.security_events WHERE severity = 'low';
RAISE NOTICE '==============================================';
RAISE NOTICE '✓ Security events insertados (datos de ejemplo)';
RAISE NOTICE ' Total: %', event_count;
RAISE NOTICE ' Críticos: %', critical_count;
RAISE NOTICE ' Altos: %', high_count;
RAISE NOTICE ' Medios: %', medium_count;
RAISE NOTICE ' Bajos: %', low_count;
RAISE NOTICE '==============================================';
END $$;