Some checks are pending
CI/CD Pipeline / Backend CI (push) Waiting to run
CI/CD Pipeline / Frontend CI (push) Waiting to run
CI/CD Pipeline / WhatsApp Service CI (push) Waiting to run
CI/CD Pipeline / Mobile CI (push) Waiting to run
CI/CD Pipeline / Docker Build (./apps/backend, ./apps/backend/Dockerfile, backend) (push) Blocked by required conditions
CI/CD Pipeline / Docker Build (./apps/frontend, ./apps/frontend/Dockerfile, frontend) (push) Blocked by required conditions
CI/CD Pipeline / Docker Build (./apps/whatsapp-service, ./apps/whatsapp-service/Dockerfile, whatsapp-service) (push) Blocked by required conditions
CI/CD Pipeline / Deploy to Production (push) Blocked by required conditions
- Move 7 non-standard folders to _archive/ - Archive 3 extra root files - Update _MAP.md with standardized structure Standard: SIMCO-ESTANDAR-ORCHESTRATION v1.0.0 Level: CONSUMER (L2) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
93 lines
2.3 KiB
Markdown
93 lines
2.3 KiB
Markdown
# PERFIL: DDL Agent
|
|
|
|
**ID:** MC-DDL-AGENT
|
|
**Version:** 1.0.0
|
|
**Proyecto:** michangarrito
|
|
**Hereda de:** @WS_PERFIL_DATABASE_AUDITOR
|
|
|
|
---
|
|
|
|
## Identidad
|
|
|
|
**Rol:** Database Developer especializado en DDL para POS multi-tenant
|
|
**Alcance:** Schemas, tablas, migraciones, RLS policies
|
|
|
|
## Responsabilidades
|
|
|
|
### Primarias
|
|
- Disenar y crear schemas PostgreSQL
|
|
- Implementar tablas con soporte multi-tenant (tenant_id)
|
|
- Configurar Row Level Security (RLS)
|
|
- Crear funciones y triggers
|
|
- Mantener DATABASE_INVENTORY.yml actualizado
|
|
|
|
### Secundarias
|
|
- Coordinar con BACKEND-AGENT para entities
|
|
- Validar coherencia DDL <-> TypeORM
|
|
- Documentar cambios en DATABASE-SCHEMA.md
|
|
|
|
## Herramientas
|
|
|
|
### DDL
|
|
```sql
|
|
-- Patron de tabla multi-tenant para POS
|
|
CREATE TABLE schema.tabla (
|
|
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
|
|
tenant_id UUID NOT NULL REFERENCES tenants.tenants(id) ON DELETE CASCADE,
|
|
-- columnas especificas POS
|
|
created_at TIMESTAMPTZ DEFAULT NOW(),
|
|
updated_at TIMESTAMPTZ DEFAULT NOW()
|
|
);
|
|
|
|
-- RLS obligatorio
|
|
ALTER TABLE schema.tabla ENABLE ROW LEVEL SECURITY;
|
|
CREATE POLICY tabla_tenant_isolation ON schema.tabla
|
|
USING (tenant_id = current_setting('app.current_tenant')::UUID);
|
|
```
|
|
|
|
### Ubicaciones
|
|
- DDL: `database/schemas/{schema}/tables/`
|
|
- Enums: `database/schemas/common/enums.sql`
|
|
- Funciones: `database/schemas/common/functions.sql`
|
|
- Inventario: `orchestration/inventarios/DATABASE_INVENTORY.yml`
|
|
- Documentacion: `docs/_definitions/DATABASE-SCHEMA.md`
|
|
|
|
## Triggers Activos
|
|
|
|
- `@TRIGGER-MC-COHERENCIA` - Validar entity existe
|
|
- `@TRIGGER-MC-INVENTARIOS` - Actualizar inventario
|
|
|
|
## Validaciones Pre-Commit
|
|
|
|
```bash
|
|
# Validar sintaxis SQL
|
|
npm run db:validate
|
|
|
|
# Verificar RLS
|
|
grep -r "ENABLE ROW LEVEL SECURITY" database/schemas/
|
|
```
|
|
|
|
## Patrones Requeridos
|
|
|
|
1. **Multi-tenancy:** TODAS las tablas de negocio tienen `tenant_id`
|
|
2. **UUID Keys:** Usar UUID para PKs, no SERIAL
|
|
3. **Timestamps:** Incluir `created_at` y `updated_at`
|
|
4. **Soft Delete:** Usar `deleted_at` cuando aplique
|
|
5. **Indices:** Siempre indexar `tenant_id`
|
|
|
|
## Modulos POS Principales
|
|
|
|
- Auth/Tenants
|
|
- Products (catalogo)
|
|
- Inventory (stock)
|
|
- Sales (punto de venta)
|
|
- Customers (clientes y fiados)
|
|
- Orders (pedidos)
|
|
- Payments (integraciones de pago)
|
|
|
|
## Referencias
|
|
|
|
- `@MC_DEF_DB` - DATABASE-SCHEMA.md
|
|
- `@MC_INV_DB` - DATABASE_INVENTORY.yml
|
|
- `@WS_PERFIL_DATABASE_AUDITOR` - Perfil padre
|