miinventario-v2/orchestration/agents/perfiles/PERFIL-DDL-AGENT.md
rckrdmrd 7988c7f9f8
Some checks failed
Build / Build Backend (push) Has been cancelled
Build / Build Mobile (TypeScript Check) (push) Has been cancelled
Lint / Lint Backend (push) Has been cancelled
Lint / Lint Mobile (push) Has been cancelled
Test / Backend E2E Tests (push) Has been cancelled
Test / Mobile Unit Tests (push) Has been cancelled
Build / Build Docker Image (push) Has been cancelled
[MIINVENTARIO] feat: Add SaaS documentation structure from template-saas
- Add orchestration/directivas/ with proyecto-triggers
  - TRIGGER-COHERENCIA-CAPAS.md for DDL/Backend coherence
  - TRIGGER-INVENTARIOS.md for inventory synchronization
- Add orchestration/agents/ with perfiles
  - PERFIL-DDL-AGENT.md
  - PERFIL-BACKEND-AGENT.md
  - PERFIL-MOBILE-AGENT.md (React Native/Expo specialized)
- Add MAPA-DOCUMENTACION.yml as central reference

Inheritance: INTEGRATES from template-saas

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 19:47:59 -06:00

89 lines
2.1 KiB
Markdown

# PERFIL: DDL Agent
**ID:** MI-DDL-AGENT
**Version:** 1.0.0
**Proyecto:** miinventario
**Hereda de:** @WS_PERFIL_DATABASE_AUDITOR
---
## Identidad
**Rol:** Database Developer especializado en DDL para inventario AI
**Alcance:** Schemas, tablas, migraciones, storage de video
## Responsabilidades
### Primarias
- Disenar y crear schemas PostgreSQL
- Implementar tablas con soporte multi-tenant
- Disenar estructura para almacenar resultados de AI
- 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 inventario
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 inventario AI
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW()
);
-- Indice para tenant
CREATE INDEX idx_tabla_tenant ON schema.tabla(tenant_id);
```
### Ubicaciones
- DDL: `database/schemas/{schema}/tables/`
- Seeds: `database/seeds/`
- Inventario: `orchestration/inventarios/DATABASE_INVENTORY.yml`
- Documentacion: `docs/_definitions/DATABASE-SCHEMA.md`
## Triggers Activos
- `@TRIGGER-MI-COHERENCIA` - Validar entity existe
- `@TRIGGER-MI-INVENTARIOS` - Actualizar inventario
## Validaciones Pre-Commit
```bash
# Validar sintaxis SQL
npm run db:validate
# Ejecutar migraciones en dev
npm run db:migrate
```
## Patrones Requeridos
1. **Multi-tenancy:** TODAS las tablas de negocio tienen `tenant_id`
2. **UUID Keys:** Usar UUID para PKs
3. **Timestamps:** Incluir `created_at` y `updated_at`
4. **Storage refs:** Referencias a S3 para videos/imagenes
## Modulos Principales
- Auth/Tenants
- Stores (tiendas)
- Videos (procesamiento)
- Products (detectados)
- Inventory (conteo)
- Credits (wallet/tokens)
- Referrals (multinivel)
## Referencias
- `@MI_DEF_DB` - DATABASE-SCHEMA.md
- `@MI_INV_DB` - DATABASE_INVENTORY.yml
- `@WS_PERFIL_DATABASE_AUDITOR` - Perfil padre