Commit Graph

12 Commits

Author SHA1 Message Date
Adrian Flores Cortes
efce73bdbd [GAP-006,007] feat: Add DDL for Digital Signatures and Audit Triggers
GAP-006: Digital Signatures
- documents.signature_type ENUM
- documents.signature_status ENUM
- documents.digital_signatures table with RLS

GAP-007: Audit Triggers
- audit schema
- audit.change_log table
- audit.log_changes() trigger function
- Triggers on 13 critical tables

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 01:15:16 -06:00
Adrian Flores Cortes
8a9db6f9d1 [GAP-001,002,003] feat(ddl): Add KPIs, tool loans and depreciation tables
- Add 12-analytics-kpis-ddl.sql with kpis_config and kpis_values tables
- Add tool_loans table with loan_status enum (GAP-002)
- Add depreciation_schedule and depreciation_entries tables (GAP-003)
- Add depreciation_method enum and calculate_monthly_depreciation function

Implements 13 SP of critical gaps identified in EPIC-003.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 00:46:00 -06:00
Adrian Flores Cortes
094cbe3ffb [EPIC-002] feat: Add user_id FK to employees + rename warehouse_type
T2.1: Renamed warehouse_type -> construction_warehouse_type
      in almacenes_proyecto to avoid naming conflict with ERP-Core

T2.3: Added user_id column to hr.employees
      - Optional FK to auth.users (employee may not have system access)
      - Unique constraint for 1:1 mapping
      - Conditional FK (only created if auth.users exists)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 00:20:02 -06:00
Adrian Flores Cortes
2b69098fd4 [EPIC-001-FK-DEBILES] feat(ddl): Add conditional FK constraints to fix weak references
Add 19 conditional FK constraints to 4 schema files:
- 06-inventory-ext: 7 FKs (warehouses, products, uom, stock_moves)
- 07-purchase-ext: 5 FKs (purchase_orders, partners, products)
- 03-hse: 3 FKs (almacen_temporal for EPP)
- 10-documents: 4 FKs (documents, users)

Features:
- Constraints are conditional (only created if target tables exist)
- Idempotent (can be re-run without errors)
- Added 6 new indexes for FK fields

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 00:00:23 -06:00
Adrian Flores Cortes
dcdc15e162 [ST-P2-002,ST-P2-003] feat: Add compound indices and JSONB schema documentation
- 11-compound-indices.sql: 14 compound indices for common queries
- docs/JSONB-SCHEMAS.md: 50+ TypeScript interfaces documenting JSONB fields
- DDL-EXECUTION-ORDER.md: Updated to include compound indices step

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 07:39:14 -06:00
Adrian Flores Cortes
f76afed513 [MAI-012] feat: Add DDL for contrato_addendas table
- Add contrato_addendas table for contract addendums/modifications
- Includes workflow status, amount changes, date extensions

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 09:08:50 -06:00
Adrian Flores Cortes
9d0457622f [MAI-009] feat: Add DDL for quality module missing tables
- Add no_conformidades table for non-conformity tracking
- Add acciones_correctivas table for corrective actions
- Add ticket_asignaciones table for ticket assignments

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 08:54:24 -06:00
Adrian Flores Cortes
80dd204db2 [MAE-016] feat: Add documents schema DDL with 11 tables and 8 ENUMs
- document_categories: Categorias jerarquicas
- documents: Registro principal
- document_versions: Control de versiones
- document_permissions: Permisos granulares
- approval_workflows: Definicion de flujos
- approval_instances: Instancias de aprobacion
- approval_steps: Pasos de aprobacion
- approval_actions: Acciones de aprobacion
- annotations: Anotaciones sobre documentos
- access_logs: Historial de acceso
- document_shares: Compartidos externos

Includes: RLS, indices, triggers, fulltext search

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 05:12:59 -06:00
Adrian Flores Cortes
e927cafc90 [MAE-015] feat: Add assets schema DDL with 11 tables and 9 ENUMs
- asset_categories: Categorias de activos
- assets: Catalogo principal de activos
- asset_assignments: Asignaciones a proyectos
- maintenance_plans: Planes de mantenimiento preventivo
- maintenance_schedules: Programacion de mantenimientos
- work_orders: Ordenes de trabajo
- work_order_parts: Refacciones utilizadas
- maintenance_history: Historial de mantenimientos
- asset_costs: Costos TCO
- asset_locations: Ubicaciones GPS
- fuel_logs: Registro de combustible

Includes: RLS, indices, triggers, TCO calculation function

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 05:11:02 -06:00
Adrian Flores Cortes
3e3d2d6eac [MAE-014] feat: Add finance schema DDL with 11 tables and 20 ENUMs
- chart_of_accounts: Catalogo de cuentas contables con jerarquia
- accounting_entries: Polizas contables
- accounting_entry_lines: Lineas de poliza
- accounts_payable: Cuentas por pagar
- accounts_receivable: Cuentas por cobrar
- bank_accounts: Cuentas bancarias
- bank_movements: Movimientos bancarios
- bank_reconciliations: Conciliacion bancaria
- ap_payments: Pagos a proveedores
- ar_payments: Cobros de clientes
- cash_flow_projections: Flujo de efectivo

Includes: RLS, indices, triggers, audit functions

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 05:08:19 -06:00
Adrian Flores Cortes
8e118a84cd [TASK-029] security: Add RLS policies for 86 construction tables
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 22:32:39 -06:00
bf97e26cdf Migración desde erp-construccion/database - Estándar multi-repo v2
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 08:11:21 -06:00