Some checks are pending
Build / Build Backend (push) Waiting to run
Build / Build Docker Image (push) Blocked by required conditions
Build / Build Mobile (TypeScript Check) (push) Waiting to run
Lint / Lint Backend (push) Waiting to run
Lint / Lint Mobile (push) Waiting to run
Test / Backend E2E Tests (push) Waiting to run
Test / Mobile Unit Tests (push) Waiting to run
- Move 5 non-standard folders to _archive/ - Archive 2 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>
89 lines
2.1 KiB
Markdown
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
|