Creates 99-additional-fk-indexes.sql with indexes for all FKs
that were identified without dedicated index coverage.
Organized by priority:
- HIGH: billing (3), notifications (1), sales (2), commissions (1)
- MEDIUM: audit (2), storage (1), webhooks (1), whatsapp (1)
- LOW: created_by/approved_by fields across multiple schemas
References: TASK-2026-02-03-REMEDIACION-BD (P1)
Based on: INFORME-INTEGRIDAD-REFERENCIAL.md analysis
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add 06-triggers.sql with trg_files_updated_at and trg_usage_updated_at
for storage.files and storage.usage tables
- Fix RLS policies in whatsapp schema to use current_setting with true
parameter to avoid errors when app.current_tenant_id is not set
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Create missing trigger function required by MLM schema triggers.
The function updates the updated_at column to CURRENT_TIMESTAMP
on row updates for mlm.structures, mlm.ranks, and mlm.nodes tables.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Added `code` VARCHAR(50) NOT NULL for programmatic use
- Added `is_active` BOOLEAN DEFAULT TRUE
- Added `metadata` JSONB DEFAULT '{}'
- Added indexes for code and is_active
- Added unique constraint for code per tenant
Aligns DDL with role.entity.ts
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Migración desde workspace-v2/projects/template-saas/apps/database
Este repositorio es parte del estándar multi-repo v2
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>