Major overhaul of drop-and-recreate-database.sh, DDL schema updates,
seed data cleanup. Add utility scripts for auth table fixes.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PostgreSQL requires generated columns to use immutable expressions.
The executed_at::date cast is not immutable due to timezone dependencies.
Changed to a regular DATE column that can be populated by the trigger.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- 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>
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>
Add 02b-hr-employees.sql and 11-infonavit.sql to execution order.
Order respects FK dependencies:
- 02b after 04 (needs fraccionamientos)
- 08 after 02b (needs employees for EPP)
- 11 at end (needs lotes)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- 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>
- Create DDL-EXECUTION-ORDER.md with schema dependencies
- Document execution order for erp-core + erp-construccion
- Add WSL commands for database recreation
- Update README.md with current schema counts (10 schemas, 143 tables, 115 ENUMs)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- 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>
- 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>