refactor: migrate from old db/ to supabase CLI structure

- Migrated database schema from db/migrations to supabase/migrations
- Added Supabase CLI configuration (config.toml, .gitignore)
- Added kiosk role and amenities tables for touch kiosks
- Added notification system for artist alerts
- Added seed data with test locations and staff
- Removed old migration scripts and documentation
- Updated tasks_mg.md with current setup

Features:
- 2 locations: ANCHOR:23 - Via KLAVA and TEST
- Kiosk role for touch screen check-in/booking
- Amenities: coffee, cocktails, mocktails for clients
- Notifications when client arrives
- 1 staff + 4 artists + 1 kiosk per location
- Services: hair, nails, makeup, lashes
This commit is contained in:
Marco Gallegos
2026-01-16 00:01:32 -06:00
parent a2054ba403
commit 18071cfb63
34 changed files with 1168 additions and 8626 deletions

View File

@@ -57,56 +57,69 @@ SALONOS - DATABASE MIGRATION COMPLETED
```sql
INSERT INTO locations (name, timezone, address, phone, is_active)
VALUES
('Salón Principal - Centro', 'America/Mexico_City', 'Av. Reforma 222, Centro Histórico, Ciudad de México', '+52 55 1234 5678', true),
('Salón Norte - Polanco', 'America/Mexico_City', 'Av. Masaryk 123, Polanco, Ciudad de México', '+52 55 2345 6789', true),
('Salón Sur - Coyoacán', 'America/Mexico_City', 'Calle Hidalgo 456, Coyoacán, Ciudad de México', '+52 55 3456 7890', true);
('ANCHOR:23 - Via KLAVA', 'America/Monterrey', 'Blvd. Moctezuma 2370, Los Pinos 2do y 3er Sector, 25204 Saltillo, Coah.', '+52 844 123 4567', true),
('TEST - Salón Principal', 'America/Monterrey', 'Av. Universidad 456, Zona Centro, 25000 Saltillo, Coah.', '+52 844 234 5678', true);
```
3. Deberías ver: `Success, no rows returned`
### 2.2 Crear Resources
### 2.2 Crear Resources (4 estaciones por salón)
1. Nuevo query, copiar y ejecutar:
```sql
-- ANCHOR:23 - Via KLAVA (4 estaciones: 1 maquillaje + 3 pedicure)
INSERT INTO resources (location_id, name, type, capacity, is_active)
SELECT
(SELECT id FROM locations WHERE name = 'Salón Principal - Centro' LIMIT 1),
'Estación ' || generate_series(1, 3)::TEXT,
'station',
(SELECT id FROM locations WHERE name = 'ANCHOR:23 - Via KLAVA' LIMIT 1),
'Estación de Maquillaje',
'station'::resource_type,
1,
true
UNION ALL
SELECT
(SELECT id FROM locations WHERE name = 'Salón Norte - Polanco' LIMIT 1),
'Estación ' || generate_series(1, 2)::TEXT,
'station',
(SELECT id FROM locations WHERE name = 'ANCHOR:23 - Via KLAVA' LIMIT 1),
'Sillón Pedicure ' || generate_series(1, 3)::TEXT,
'station'::resource_type,
1,
true
UNION ALL
-- TEST - Salón Principal (4 estaciones: 1 maquillaje + 3 pedicure)
SELECT
(SELECT id FROM locations WHERE name = 'TEST - Salón Principal' LIMIT 1),
'Estación de Maquillaje',
'station'::resource_type,
1,
true
UNION ALL
SELECT
(SELECT id FROM locations WHERE name = 'Salón Sur - Coyoacán' LIMIT 1),
'Estación 1',
'station',
(SELECT id FROM locations WHERE name = 'TEST - Salón Principal' LIMIT 1),
'Sillón Pedicure ' || generate_series(1, 3)::TEXT,
'station'::resource_type,
1,
true;
```
2. Deberías ver: `Success, no rows returned`
### 2.3 Crear Staff
### 2.3 Crear Staff (5 empleadas por salón)
1. Nuevo query, copiar y ejecutar:
```sql
INSERT INTO staff (user_id, location_id, role, display_name, phone, is_active)
VALUES
(uuid_generate_v4(), (SELECT id FROM locations WHERE name = 'Salón Principal - Centro' LIMIT 1), 'admin', 'Admin Principal', '+52 55 1111 2222', true),
(uuid_generate_v4(), (SELECT id FROM locations WHERE name = 'Salón Principal - Centro' LIMIT 1), 'manager', 'Manager Centro', '+52 55 2222 3333', true),
(uuid_generate_v4(), (SELECT id FROM locations WHERE name = 'Salón Norte - Polanco' LIMIT 1), 'manager', 'Manager Polanco', '+52 55 6666 7777', true),
(uuid_generate_v4(), (SELECT id FROM locations WHERE name = 'Salón Principal - Centro' LIMIT 1), 'staff', 'Staff Coordinadora', '+52 55 3333 4444', true),
(uuid_generate_v4(), (SELECT id FROM locations WHERE name = 'Salón Principal - Centro' LIMIT 1), 'artist', 'Artist María García', '+52 55 4444 5555', true),
(uuid_generate_v4(), (SELECT id FROM locations WHERE name = 'Salón Principal - Centro' LIMIT 1), 'artist', 'Artist Ana Rodríguez', '+52 55 5555 6666', true),
(uuid_generate_v4(), (SELECT id FROM locations WHERE name = 'Salón Norte - Polanco' LIMIT 1), 'artist', 'Artist Carla López', '+52 55 7777 8888', true),
(uuid_generate_v4(), (SELECT id FROM locations WHERE name = 'Salón Sur - Coyoacán' LIMIT 1), 'artist', 'Artist Laura Martínez', '+52 55 8888 9999', true);
-- ANCHOR:23 - Via KLAVA (5 empleadas)
(uuid_generate_v4(), (SELECT id FROM locations WHERE name = 'ANCHOR:23 - Via KLAVA' LIMIT 1), 'admin', 'Mariana González', '+52 844 111 2222', true),
(uuid_generate_v4(), (SELECT id FROM locations WHERE name = 'ANCHOR:23 - Via KLAVA' LIMIT 1), 'manager', 'Daniela Sánchez', '+52 844 222 3333', true),
(uuid_generate_v4(), (SELECT id FROM locations WHERE name = 'ANCHOR:23 - Via KLAVA' LIMIT 1), 'artist', 'Karla Rodríguez', '+52 844 333 4444', true),
(uuid_generate_v4(), (SELECT id FROM locations WHERE name = 'ANCHOR:23 - Via KLAVA' LIMIT 1), 'artist', 'Fernanda Martínez', '+52 844 444 5555', true),
(uuid_generate_v4(), (SELECT id FROM locations WHERE name = 'ANCHOR:23 - Via KLAVA' LIMIT 1), 'artist', 'Paola Hernández', '+52 844 555 6666', true),
-- TEST - Salón Principal (5 empleadas)
(uuid_generate_v4(), (SELECT id FROM locations WHERE name = 'TEST - Salón Principal' LIMIT 1), 'manager', 'Sofía Ramírez', '+52 844 666 7777', true),
(uuid_generate_v4(), (SELECT id FROM locations WHERE name = 'TEST - Salón Principal' LIMIT 1), 'artist', 'Valeria López', '+52 844 777 8888', true),
(uuid_generate_v4(), (SELECT id FROM locations WHERE name = 'TEST - Salón Principal' LIMIT 1), 'artist', 'Andrea García', '+52 844 888 9999', true),
(uuid_generate_v4(), (SELECT id FROM locations WHERE name = 'TEST - Salón Principal' LIMIT 1), 'artist', 'Camila Torres', '+52 844 999 0000', true),
(uuid_generate_v4(), (SELECT id FROM locations WHERE name = 'TEST - Salón Principal' LIMIT 1), 'artist', 'Regina Flores', '+52 844 000 1111', true);
```
2. Deberías ver: `Success, no rows returned`
@@ -117,26 +130,61 @@ VALUES
```sql
INSERT INTO services (name, description, duration_minutes, base_price, requires_dual_artist, premium_fee_enabled, is_active)
VALUES
('Corte y Estilizado', 'Corte de cabello profesional con lavado y estilizado', 60, 500.00, false, false, true),
('Color Completo', 'Tinte completo con protección capilar', 120, 1200.00, false, true, true),
('Balayage Premium', 'Técnica de balayage con productos premium', 180, 2000.00, true, true, true),
('Tratamiento Kératina', 'Tratamiento de kératina para cabello dañado', 90, 1500.00, false, false, true),
('Peinado Evento', 'Peinado para eventos especiales', 45, 800.00, false, true, true),
('Servicio Express (Dual Artist)', 'Servicio rápido con dos artists simultáneas', 30, 600.00, true, true, true);
('Maquillaje Social', 'Maquillaje para eventos sociales', 45, 450.00, false, false, true),
('Maquillaje de Novia', 'Maquillaje profesional para novias', 90, 1200.00, false, true, true),
('Pedicure Básico', 'Pedicure con esmaltado tradicional', 45, 300.00, false, false, true),
('Pedicure Spa', 'Pedicure con exfoliación y masaje', 60, 450.00, false, false, true),
('Pedicure Premium', 'Pedicure completo con tratamiento de parafina', 75, 600.00, false, true, true),
('Uñas Acrilicas', 'Aplicación de uñas acrílicas con diseño', 90, 550.00, false, false, true),
('Diseño de Uñas', 'Diseño artístico en uñas naturales o acrílicas', 30, 200.00, false, true, true);
```
2. Deberías ver: `Success, no rows returned`
### 2.4.1 Agregar Nuevos Tiers de Clientes (IMPORTANTE)
**⚠️ Ejecutar ANTES de crear customers**
1. Nuevo query, copiar y ejecutar:
```sql
-- Agregar 'black' tier
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM pg_enum
WHERE enumlabel = 'black'
AND enumtypid = (SELECT oid FROM pg_type WHERE typname = 'customer_tier')
) THEN
ALTER TYPE customer_tier ADD VALUE 'black';
END IF;
END $$;
-- Agregar 'VIP' tier
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM pg_enum
WHERE enumlabel = 'VIP'
AND enumtypid = (SELECT oid FROM pg_type WHERE typname = 'customer_tier')
) THEN
ALTER TYPE customer_tier ADD VALUE 'VIP';
END IF;
END $$;
```
2. Deberías ver: `Success, no rows returned` (dos veces)
### 2.5 Crear Customers
1. Nuevo query, copiar y ejecutar:
```sql
INSERT INTO customers (user_id, first_name, last_name, email, phone, tier, notes, total_spent, total_visits, last_visit_date, is_active)
VALUES
(uuid_generate_v4(), 'Sofía', 'Ramírez', 'sofia.ramirez@example.com', '+52 55 1111 1111', 'gold', 'Cliente VIP. Prefiere Artists María y Ana.', 15000.00, 25, '2025-12-20', true),
(uuid_generate_v4(), 'Valentina', 'Hernández', 'valentina.hernandez@example.com', '+52 55 2222 2222', 'gold', 'Cliente regular. Prefiere horarios de la mañana.', 8500.00, 15, '2025-12-15', true),
(uuid_generate_v4(), 'Camila', 'López', 'camila.lopez@example.com', '+52 55 3333 3333', 'free', 'Nueva cliente. Referida por Valentina.', 500.00, 1, '2025-12-10', true),
(uuid_generate_v4(), 'Isabella', 'García', 'isabella.garcia@example.com', '+52 55 4444 4444', 'gold', 'Cliente VIP. Requiere servicio de Balayage.', 22000.00, 30, '2025-12-18', true);
(uuid_generate_v4(), 'María José', 'Villarreal', 'mariajose.villarreal@example.com', '+52 844 111 1111', 'gold', 'Cliente VIP. Prefiere maquillaje de novia.', 12000.00, 20, '2026-01-10', true),
(uuid_generate_v4(), 'Ana Paula', 'Garza', 'anapaula.garza@example.com', '+52 844 222 2222', 'gold', 'Cliente regular. Prefiere pedicure premium.', 8500.00, 15, '2026-01-08', true),
(uuid_generate_v4(), 'Lucía', 'Treviño', 'lucia.trevino@example.com', '+52 844 333 3333', 'free', 'Nueva cliente. Referida por Ana Paula.', 450.00, 2, '2026-01-05', true),
(uuid_generate_v4(), 'Gabriela', 'Saldaña', 'gabriela.saldana@example.com', '+52 844 444 4444', 'black', 'Cliente Black. Eventos corporativos.', 25000.00, 35, '2026-01-12', true),
(uuid_generate_v4(), 'Fernanda', 'Cárdenas', 'fernanda.cardenas@example.com', '+52 844 555 5555', 'VIP', 'Cliente VIP. Requiere atención personalizada.', 45000.00, 50, '2026-01-14', true);
```
2. Deberías ver: `Success, no rows returned`
@@ -145,9 +193,10 @@ VALUES
1. Nuevo query, copiar y ejecutar:
```sql
SELECT reset_weekly_invitations_for_customer((SELECT id FROM customers WHERE email = 'sofia.ramirez@example.com' LIMIT 1));
SELECT reset_weekly_invitations_for_customer((SELECT id FROM customers WHERE email = 'valentina.hernandez@example.com' LIMIT 1));
SELECT reset_weekly_invitations_for_customer((SELECT id FROM customers WHERE email = 'isabella.garcia@example.com' LIMIT 1));
SELECT reset_weekly_invitations_for_customer((SELECT id FROM customers WHERE email = 'mariajose.villarreal@example.com' LIMIT 1));
SELECT reset_weekly_invitations_for_customer((SELECT id FROM customers WHERE email = 'anapaula.garza@example.com' LIMIT 1));
SELECT reset_weekly_invitations_for_customer((SELECT id FROM customers WHERE email = 'gabriela.saldana@example.com' LIMIT 1));
SELECT reset_weekly_invitations_for_customer((SELECT id FROM customers WHERE email = 'fernanda.cardenas@example.com' LIMIT 1));
```
2. Deberías ver:
@@ -178,49 +227,64 @@ INSERT INTO bookings (
notes
)
SELECT
(SELECT id FROM customers WHERE email = 'sofia.ramirez@example.com' LIMIT 1),
(SELECT id FROM staff WHERE display_name = 'Artist María García' LIMIT 1),
(SELECT id FROM locations WHERE name = 'Salón Principal - Centro' LIMIT 1),
(SELECT id FROM resources WHERE location_id = (SELECT id FROM locations WHERE name = 'Salón Principal - Centro' LIMIT 1) LIMIT 1),
(SELECT id FROM services WHERE name = 'Balayage Premium' LIMIT 1),
(SELECT id FROM customers WHERE email = 'mariajose.villarreal@example.com' LIMIT 1),
(SELECT id FROM staff WHERE display_name = 'Karla Rodríguez' LIMIT 1),
(SELECT id FROM locations WHERE name = 'ANCHOR:23 - Via KLAVA' LIMIT 1),
(SELECT id FROM resources WHERE name = 'Estación de Maquillaje' AND location_id = (SELECT id FROM locations WHERE name = 'ANCHOR:23 - Via KLAVA' LIMIT 1) LIMIT 1),
(SELECT id FROM services WHERE name = 'Maquillaje de Novia' LIMIT 1),
NOW() + INTERVAL '1 day',
NOW() + INTERVAL '4 hours',
'confirmed',
200.00,
2000.00,
true,
'pay_test_001',
'Balayage Premium para Sofía'
UNION ALL
SELECT
(SELECT id FROM customers WHERE email = 'valentina.hernandez@example.com' LIMIT 1),
(SELECT id FROM staff WHERE display_name = 'Artist Ana Rodríguez' LIMIT 1),
(SELECT id FROM locations WHERE name = 'Salón Principal - Centro' LIMIT 1),
(SELECT id FROM resources WHERE location_id = (SELECT id FROM locations WHERE name = 'Salón Principal - Centro' LIMIT 1) LIMIT 1),
(SELECT id FROM services WHERE name = 'Color Completo' LIMIT 1),
NOW() + INTERVAL '2 days',
NOW() + INTERVAL '4 hours',
NOW() + INTERVAL '1 day 1 hour 30 minutes',
'confirmed',
200.00,
1200.00,
true,
'pay_test_002',
'Color Completo para Valentina'
'pay_test_001',
'Maquillaje de novia para María José'
UNION ALL
SELECT
(SELECT id FROM customers WHERE email = 'camila.lopez@example.com' LIMIT 1),
(SELECT id FROM staff WHERE display_name = 'Artist María García' LIMIT 1),
(SELECT id FROM locations WHERE name = 'Salón Principal - Centro' LIMIT 1),
(SELECT id FROM resources WHERE location_id = (SELECT id FROM locations WHERE name = 'Salón Principal - Centro' LIMIT 1) LIMIT 1),
(SELECT id FROM services WHERE name = 'Corte y Estilizado' LIMIT 1),
(SELECT id FROM customers WHERE email = 'anapaula.garza@example.com' LIMIT 1),
(SELECT id FROM staff WHERE display_name = 'Fernanda Martínez' LIMIT 1),
(SELECT id FROM locations WHERE name = 'ANCHOR:23 - Via KLAVA' LIMIT 1),
(SELECT id FROM resources WHERE name = 'Sillón Pedicure 1' AND location_id = (SELECT id FROM locations WHERE name = 'ANCHOR:23 - Via KLAVA' LIMIT 1) LIMIT 1),
(SELECT id FROM services WHERE name = 'Pedicure Premium' LIMIT 1),
NOW() + INTERVAL '2 days',
NOW() + INTERVAL '2 days 1 hour 15 minutes',
'confirmed',
100.00,
600.00,
true,
'pay_test_002',
'Pedicure Premium para Ana Paula'
UNION ALL
SELECT
(SELECT id FROM customers WHERE email = 'lucia.trevino@example.com' LIMIT 1),
(SELECT id FROM staff WHERE display_name = 'Valeria López' LIMIT 1),
(SELECT id FROM locations WHERE name = 'TEST - Salón Principal' LIMIT 1),
(SELECT id FROM resources WHERE name = 'Sillón Pedicure 2' AND location_id = (SELECT id FROM locations WHERE name = 'TEST - Salón Principal' LIMIT 1) LIMIT 1),
(SELECT id FROM services WHERE name = 'Pedicure Básico' LIMIT 1),
NOW() + INTERVAL '3 days',
NOW() + INTERVAL '1 hour',
NOW() + INTERVAL '3 days 45 minutes',
'confirmed',
50.00,
500.00,
300.00,
true,
'pay_test_003',
'Primer corte para Camila';
'Primer pedicure para Lucía'
UNION ALL
SELECT
(SELECT id FROM customers WHERE email = 'gabriela.saldana@example.com' LIMIT 1),
(SELECT id FROM staff WHERE display_name = 'Paola Hernández' LIMIT 1),
(SELECT id FROM locations WHERE name = 'ANCHOR:23 - Via KLAVA' LIMIT 1),
(SELECT id FROM resources WHERE name = 'Estación de Maquillaje' AND location_id = (SELECT id FROM locations WHERE name = 'ANCHOR:23 - Via KLAVA' LIMIT 1) LIMIT 1),
(SELECT id FROM services WHERE name = 'Maquillaje Social' LIMIT 1),
NOW() + INTERVAL '4 days',
NOW() + INTERVAL '4 days 45 minutes',
'confirmed',
0.00,
450.00,
true,
'pay_test_004',
'Maquillaje para evento corporativo';
```
2. Deberías ver: `Success, no rows returned`
@@ -247,19 +311,21 @@ SELECT 'Bookings: ' || COUNT(*) FROM bookings;
2. Deberías ver:
```
resumen
Locations: 3
Resources: 6
Staff: 8
Services: 6
Customers: 4
Invitaciones: 15
Bookings: 3
Locations: 2
Resources: 8
Staff: 10
Services: 7
Customers: 5
Invitaciones: 20
Bookings: 4
```
**Si ves números diferentes:**
- Verifica que todos los queries anteriores se ejecutaron correctamente
- Revisa los errores (si hubo)
**Nota:** Las invitaciones solo se crean para clientes Gold, Black y VIP (4 clientes × 5 invitaciones = 20)
---
## 📋 PASO 3: CREAR USUARIOS AUTH (10 min)
@@ -277,7 +343,7 @@ Bookings: 3
### 3.3 Crear Usuario Customer (para probar)
1. Clic en botón "Add user"
2. Email: `sofia.ramirez@example.com`
2. Email: `mariajose.villarreal@example.com`
3. Password: `Customer123!`
4. **Auto Confirm User:** ON (marcar la casilla)
5. Clic en "Create user"
@@ -286,7 +352,7 @@ Bookings: 3
### 3.4 Verificar Usuarios
1. En la página de Auth Users, deberías ver 2 usuarios:
- admin@salonos.com
- sofia.ramirez@example.com
- mariajose.villarreal@example.com
---
@@ -300,14 +366,14 @@ Bookings: 3
-- REEMPLAZA [USER_ID_DEL_CUSTOMER] con el ID que copiaste del paso 3.3
UPDATE customers
SET user_id = '[USER_ID_DEL_CUSTOMER]'
WHERE email = 'sofia.ramirez@example.com';
WHERE email = 'mariajose.villarreal@example.com';
```
3. Ejemplo de cómo debe verse (NO ejecutar esto, es solo ejemplo):
```sql
UPDATE customers
SET user_id = '01234567-89ab-cdef-0123-456789abcdef'
WHERE email = 'sofia.ramirez@example.com';
WHERE email = 'mariajose.villarreal@example.com';
```
### 4.2 Verificar Actualización
@@ -321,7 +387,7 @@ SELECT
au.email as auth_user_email
FROM customers c
LEFT JOIN auth.users au ON c.user_id = au.id
WHERE c.email = 'sofia.ramirez@example.com';
WHERE c.email = 'mariajose.villarreal@example.com';
```
2. Deberías ver `true` en la columna `user_id_set`
@@ -373,14 +439,15 @@ LIMIT 1;
**Antes de ir a la junta, marca cada paso:**
- [ ] PASO 1: Migraciones ejecutadas (verificar mensaje "MIGRATION COMPLETED")
- [ ] PASO 2.1: Locations creadas (3)
- [ ] PASO 2.2: Resources creados (6)
- [ ] PASO 2.3: Staff creado (8)
- [ ] PASO 2.4: Services creados (6)
- [ ] PASO 2.5: Customers creados (4)
- [ ] PASO 2.6: Invitaciones creadas (15)
- [ ] PASO 2.7: Bookings creados (3)
- [ ] PASO 2.8: Verificación correcta (3-6-8-6-4-15-3)
- [ ] PASO 2.1: Locations creadas (2 - Saltillo)
- [ ] PASO 2.2: Resources creados (8 - 4 por salón)
- [ ] PASO 2.3: Staff creado (10 - 5 por salón)
- [ ] PASO 2.4: Services creados (7 - maquillaje y pedicure)
- [ ] PASO 2.4.1: Nuevos tiers agregados (black, VIP)
- [ ] PASO 2.5: Customers creados (5 - varios tiers)
- [ ] PASO 2.6: Invitaciones creadas (20 - 4 clientes premium)
- [ ] PASO 2.7: Bookings creados (4)
- [ ] PASO 2.8: Verificación correcta (2-8-10-7-5-20-4)
- [ ] PASO 3.2: Usuario Admin creado
- [ ] PASO 3.3: Usuario Customer creado
- [ ] PASO 3.4: Verificación Auth Users correcta
@@ -421,7 +488,7 @@ Guarda esto en un lugar seguro:
- Password: `Admin123!`
**Customer (para probar):**
- Email: `sofia.ramirez@example.com`
- Email: `mariajose.villarreal@example.com`
- Password: `Customer123!`
---