🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
251 lines
6.9 KiB
Markdown
251 lines
6.9 KiB
Markdown
# Traza de Tareas - Database Agent
|
|
|
|
## Registro de Tareas Ejecutadas
|
|
|
|
Este archivo mantiene el historial de todas las tareas ejecutadas por agentes de base de datos en el proyecto ERP Core.
|
|
|
|
---
|
|
|
|
## Historial de Tareas
|
|
|
|
### 2026-01-07 - DDL-004 - COMPLETADO
|
|
**Agente:** Database-Agent
|
|
**Sprint:** Sprint 8 - Reports & Dashboards
|
|
**Descripción:** Implementación DDL de schema reports completo
|
|
**Specs cubiertas:**
|
|
- RF-REPORT-001: Reportes Predefinidos
|
|
- RF-REPORT-002: Dashboards
|
|
- RF-REPORT-003: Report Builder
|
|
- RF-REPORT-004: Reportes Programados
|
|
|
|
**Archivos creados:**
|
|
- database/ddl/14-reports.sql
|
|
|
|
**Contenido implementado:**
|
|
```yaml
|
|
tablas_nuevas: 12
|
|
reportes:
|
|
- reports.report_definitions
|
|
- reports.report_executions
|
|
- reports.report_schedules
|
|
- reports.report_recipients
|
|
- reports.schedule_executions
|
|
- reports.custom_reports
|
|
dashboards:
|
|
- reports.dashboards
|
|
- reports.dashboard_widgets
|
|
- reports.widget_queries
|
|
data_model:
|
|
- reports.data_model_entities
|
|
- reports.data_model_fields
|
|
- reports.data_model_relationships
|
|
|
|
enums_nuevos: 7
|
|
- reports.report_type
|
|
- reports.execution_status
|
|
- reports.export_format
|
|
- reports.delivery_method
|
|
- reports.widget_type (15 tipos)
|
|
- reports.param_type
|
|
- reports.filter_operator
|
|
|
|
rls_policies: 7
|
|
- Todas las tablas con tenant_isolation
|
|
```
|
|
|
|
**Archivos modificados:**
|
|
- database/scripts/create-database.sh (agregado 14-reports.sql al array DDL_FILES)
|
|
|
|
**Resultado:** Éxito
|
|
**Validación:** Base de datos recreada exitosamente con ./recreate-database.sh --force
|
|
|
|
---
|
|
|
|
### 2025-12-08 - DDL-002 - COMPLETADO
|
|
**Agente:** Database-Agent
|
|
**Descripción:** Implementación DDL de extensiones de inventario (SVL, Lotes, Conteos)
|
|
**Specs cubiertas:**
|
|
- SPEC-VALORACION-INVENTARIO.md
|
|
- SPEC-TRAZABILIDAD-LOTES-SERIES.md
|
|
- SPEC-INVENTARIOS-CICLICOS.md
|
|
|
|
**Archivos creados:**
|
|
- database/ddl/05-inventory-extensions.sql
|
|
|
|
**Contenido implementado:**
|
|
```yaml
|
|
tablas_nuevas: 10
|
|
valoracion_svl:
|
|
- inventory.stock_valuation_layers
|
|
- inventory.category_stock_accounts
|
|
- inventory.valuation_settings
|
|
lotes_series:
|
|
- inventory.lots
|
|
- inventory.move_line_consume_rel
|
|
- inventory.removal_strategies
|
|
conteos_ciclicos:
|
|
- inventory.inventory_count_sessions
|
|
- inventory.inventory_count_lines
|
|
- inventory.abc_classification_rules
|
|
- inventory.product_abc_classification
|
|
|
|
funciones_nuevas: 7
|
|
- inventory.run_fifo()
|
|
- inventory.calculate_abc_classification()
|
|
- inventory.get_pending_counts()
|
|
- inventory.mark_quants_outdated()
|
|
- inventory.compute_lot_expiration_dates()
|
|
- inventory.refresh_product_valuation_summary()
|
|
- inventory.update_session_stats()
|
|
|
|
vistas_nuevas: 3
|
|
- inventory.product_valuation_summary (materialized)
|
|
- inventory.expiring_lots_view
|
|
- inventory.location_count_summary_view
|
|
|
|
columnas_extendidas: 30+
|
|
- products: tracking, expiration_time, use_time, removal_time, etc.
|
|
- product_categories: cost_method, valuation_method, removal_strategy
|
|
- quants: lot_id, in_date, inventory_quantity, etc.
|
|
- locations: cyclic_inventory_frequency, abc_classification
|
|
- stock_move_lines: lot_id, lot_name, tracking
|
|
- stock_moves: is_inventory, inventory_session_id
|
|
```
|
|
|
|
**Resultado:** Éxito
|
|
**Validación:** Pendiente ejecución de carga limpia
|
|
|
|
---
|
|
|
|
### 2025-12-08 - DDL-001 - COMPLETADO
|
|
**Agente:** Database-Agent
|
|
**Descripción:** Implementación DDL de extensiones de autenticación (2FA, API Keys, OAuth2, ACL)
|
|
**Specs cubiertas:**
|
|
- SPEC-TWO-FACTOR-AUTHENTICATION.md
|
|
- SPEC-SEGURIDAD-API-KEYS-PERMISOS.md
|
|
- SPEC-OAUTH2-SOCIAL-LOGIN.md
|
|
|
|
**Archivos creados:**
|
|
- database/ddl/01-auth-extensions.sql
|
|
|
|
**Contenido implementado:**
|
|
```yaml
|
|
tablas_nuevas: 16
|
|
groups_herencia:
|
|
- auth.groups
|
|
- auth.group_implied
|
|
- auth.user_groups
|
|
acl_model_access:
|
|
- auth.models
|
|
- auth.model_access
|
|
- auth.record_rules
|
|
- auth.rule_groups
|
|
- auth.model_fields
|
|
- auth.field_permissions
|
|
api_keys:
|
|
- auth.api_keys
|
|
two_factor_auth:
|
|
- auth.trusted_devices
|
|
- auth.verification_codes
|
|
- auth.mfa_audit_log
|
|
oauth2:
|
|
- auth.oauth_providers
|
|
- auth.oauth_user_links
|
|
- auth.oauth_states
|
|
|
|
funciones_nuevas: 6
|
|
- auth.get_user_effective_groups()
|
|
- auth.check_model_access()
|
|
- auth.cleanup_expired_oauth_states()
|
|
- auth.cleanup_expired_verification_codes()
|
|
- auth.cleanup_expired_trusted_devices()
|
|
- auth.cleanup_expired_api_keys()
|
|
|
|
vistas_nuevas: 2
|
|
- auth.users_oauth_summary
|
|
- auth.user_model_access_view
|
|
|
|
columnas_extendidas_users: 9
|
|
- mfa_enabled, mfa_method, mfa_secret
|
|
- backup_codes, backup_codes_count
|
|
- mfa_setup_at, last_2fa_verification
|
|
- oauth_only, primary_oauth_provider_id
|
|
```
|
|
|
|
**Archivos modificados:**
|
|
- database/scripts/create-database.sh (agregados DDL faltantes al orden de ejecución)
|
|
|
|
**Resultado:** Éxito
|
|
**Validación:** Pendiente ejecución de carga limpia
|
|
|
|
---
|
|
|
|
### 2025-12-05 - INIT-001 - COMPLETADO
|
|
**Agente:** Migración
|
|
**Descripción:** Migración inicial de database desde workspace-erp-inmobiliaria
|
|
**Archivos creados:**
|
|
- database/ddl/*
|
|
- database/migrations/*
|
|
- database/seeds/*
|
|
|
|
**Resultado:** Éxito
|
|
**Notas:** Estructura de BD migrada desde erp-generic.
|
|
|
|
---
|
|
|
|
## Próximas Tareas Asignadas
|
|
|
|
| ID | Descripción | Agente | Prioridad | Specs |
|
|
|----|-------------|--------|-----------|-------|
|
|
| DB-003 | Ejecutar carga limpia para validar DDL nuevos | Database-Agent | P0 | N/A |
|
|
| DB-004 | Implementar DDL para secuencias (ir.sequence) | Database-Agent | P1 | SPEC-SISTEMA-SECUENCIAS.md |
|
|
| DB-005 | Implementar DDL para reportes financieros | Database-Agent | P1 | SPEC-REPORTES-FINANCIEROS.md |
|
|
| DB-006 | Implementar seeds de roles/permisos | Database-Agent | P2 | N/A |
|
|
|
|
---
|
|
|
|
## Validación de Carga Limpia
|
|
|
|
### Checklist (Pendiente)
|
|
|
|
```markdown
|
|
- [ ] Recreación completa ejecuta sin errores
|
|
- [ ] Todas las tablas se crean correctamente (144 total)
|
|
- [ ] Todos los índices se crean
|
|
- [ ] Todas las funciones y triggers se crean
|
|
- [ ] Todas las RLS policies se aplican
|
|
- [ ] Seeds se cargan sin errores
|
|
- [ ] No hay warnings en el log
|
|
```
|
|
|
|
### Comando de Validación
|
|
|
|
```bash
|
|
cd projects/erp-suite/apps/erp-core/database
|
|
./scripts/reset-database.sh # DDL + seeds dev (por defecto)
|
|
./scripts/reset-database.sh --force # Sin confirmación (CI/CD)
|
|
./scripts/reset-database.sh --no-seeds # Solo DDL, sin seeds
|
|
./scripts/reset-database.sh --env prod # Seeds de producción
|
|
```
|
|
|
|
---
|
|
|
|
## Política de Carga Limpia
|
|
|
|
**Directiva:** `core/orchestration/directivas/legacy/DIRECTIVA-POLITICA-CARGA-LIMPIA.md`
|
|
|
|
**Principios:**
|
|
1. DDL-First: Los archivos DDL son la fuente de verdad
|
|
2. NUNCA ejecutar ALTER/CREATE directo en BD
|
|
3. SIEMPRE validar con recreación completa
|
|
4. La BD debe poder recrearse 100% desde DDL
|
|
|
|
**Prohibiciones:**
|
|
- Ejecutar ALTER TABLE directo sin actualizar DDL
|
|
- Crear carpeta migrations/
|
|
- Crear archivos fix-*.sql, patch-*.sql, hotfix-*.sql
|
|
- Dejar BD y DDL desincronizados
|
|
|
|
---
|
|
*Última actualización: 2025-12-08*
|