workspace-v1/projects/erp-construccion/database/validate-clean-load-policy.sh
rckrdmrd 66161b1566 feat: Workspace-v1 complete migration with NEXUS v3.4
Sistema NEXUS v3.4 migrado con:

Estructura principal:
- core/orchestration: Sistema SIMCO + CAPVED (27 directivas, 28 perfiles)
- core/catalog: Catalogo de funcionalidades reutilizables
- shared/knowledge-base: Base de conocimiento compartida
- devtools/scripts: Herramientas de desarrollo
- control-plane/registries: Control de servicios y CI/CD
- orchestration/: Configuracion de orquestacion de agentes

Proyectos incluidos (11):
- gamilit (submodule -> GitHub)
- trading-platform (OrbiquanTIA)
- erp-suite con 5 verticales:
  - erp-core, construccion, vidrio-templado
  - mecanicas-diesel, retail, clinicas
- betting-analytics
- inmobiliaria-analytics
- platform_marketing_content
- pos-micro, erp-basico

Configuracion:
- .gitignore completo para Node.js/Python/Docker
- gamilit como submodule (git@github.com:rckrdmrd/gamilit-workspace.git)
- Sistema de puertos estandarizado (3005-3199)

Generated with NEXUS v3.4 Migration System
EPIC-010: Configuracion Git y Repositorios
2026-01-04 03:37:42 -06:00

154 lines
6.6 KiB
Bash
Executable File

#!/bin/bash
# =============================================================================
# VALIDATE CLEAN LOAD POLICY
# =============================================================================
# Script de validacion de cumplimiento de DIRECTIVA-POLITICA-CARGA-LIMPIA.md
#
# Uso: ./validate-clean-load-policy.sh
# =============================================================================
set -e
# Colores
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
# Configuracion
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
VIOLATIONS=0
echo -e "${BLUE}=============================================================================${NC}"
echo -e "${BLUE} VALIDACION DE POLITICA DE CARGA LIMPIA${NC}"
echo -e "${BLUE}=============================================================================${NC}"
echo ""
# =============================================================================
# CHECK 1: No debe existir carpeta migrations/
# =============================================================================
echo -e "${YELLOW}[1/6] Verificando que NO existe carpeta migrations/...${NC}"
if [ -d "$SCRIPT_DIR/migrations" ]; then
echo -e "${RED}ERROR: Carpeta migrations/ detectada (PROHIBIDA)${NC}"
echo -e "${RED} Path: $SCRIPT_DIR/migrations${NC}"
echo -e "${YELLOW} Solucion: Eliminar carpeta y mover contenido a schemas/${NC}"
VIOLATIONS=$((VIOLATIONS + 1))
else
echo -e "${GREEN}OK - No existe carpeta migrations/${NC}"
fi
echo ""
# =============================================================================
# CHECK 2: No deben existir archivos fix-*.sql
# =============================================================================
echo -e "${YELLOW}[2/6] Verificando que NO existen archivos fix-*.sql...${NC}"
FIX_FILES=$(find "$SCRIPT_DIR" -name "fix-*.sql" -o -name "patch-*.sql" -o -name "hotfix-*.sql" 2>/dev/null)
if [ -n "$FIX_FILES" ]; then
echo -e "${RED}ERROR: Archivos fix/patch detectados (PROHIBIDOS):${NC}"
echo "$FIX_FILES" | while read -r file; do
echo -e "${RED} - $file${NC}"
done
echo -e "${YELLOW} Solucion: Incorporar cambios en DDL base y eliminar fixes${NC}"
VIOLATIONS=$((VIOLATIONS + 1))
else
echo -e "${GREEN}OK - No existen archivos fix/patch${NC}"
fi
echo ""
# =============================================================================
# CHECK 3: No deben existir archivos migration-*.sql o NNN-*.sql numerados
# =============================================================================
echo -e "${YELLOW}[3/6] Verificando que NO existen archivos tipo migration...${NC}"
MIGRATION_FILES=$(find "$SCRIPT_DIR" -regex ".*[0-9][0-9][0-9][-_].*\.sql" ! -path "*/schemas/*" 2>/dev/null)
if [ -n "$MIGRATION_FILES" ]; then
echo -e "${RED}ERROR: Archivos tipo migration detectados (PROHIBIDOS):${NC}"
echo "$MIGRATION_FILES" | while read -r file; do
echo -e "${RED} - $file${NC}"
done
echo -e "${YELLOW} Solucion: Mover a schemas/ con nomenclatura correcta${NC}"
VIOLATIONS=$((VIOLATIONS + 1))
else
echo -e "${GREEN}OK - No existen archivos tipo migration fuera de schemas/${NC}"
fi
echo ""
# =============================================================================
# CHECK 4: Debe existir script drop-and-recreate-database.sh
# =============================================================================
echo -e "${YELLOW}[4/6] Verificando que existe drop-and-recreate-database.sh...${NC}"
if [ -f "$SCRIPT_DIR/drop-and-recreate-database.sh" ]; then
if [ -x "$SCRIPT_DIR/drop-and-recreate-database.sh" ]; then
echo -e "${GREEN}OK - Script existe y es ejecutable${NC}"
else
echo -e "${YELLOW}WARN: Script existe pero no es ejecutable${NC}"
echo -e "${YELLOW} Solucion: chmod +x drop-and-recreate-database.sh${NC}"
fi
else
echo -e "${RED}ERROR: No existe drop-and-recreate-database.sh (REQUERIDO)${NC}"
echo -e "${YELLOW} Solucion: Crear script de recreacion limpia${NC}"
VIOLATIONS=$((VIOLATIONS + 1))
fi
echo ""
# =============================================================================
# CHECK 5: Deben existir archivos DDL en schemas/
# =============================================================================
echo -e "${YELLOW}[5/6] Verificando que existen archivos DDL en schemas/...${NC}"
DDL_COUNT=$(find "$SCRIPT_DIR/schemas" -name "*.sql" -type f 2>/dev/null | wc -l)
if [ "$DDL_COUNT" -gt 0 ]; then
echo -e "${GREEN}OK - Encontrados $DDL_COUNT archivos DDL en schemas/${NC}"
find "$SCRIPT_DIR/schemas" -name "*.sql" -type f | sort | while read -r file; do
echo -e " - $(basename "$file")"
done
else
echo -e "${YELLOW}WARN: No hay archivos DDL en schemas/${NC}"
echo -e "${YELLOW} La base de datos puede quedar vacia${NC}"
fi
echo ""
# =============================================================================
# CHECK 6: Debe existir archivo de inicializacion
# =============================================================================
echo -e "${YELLOW}[6/6] Verificando archivo de inicializacion...${NC}"
if [ -f "$SCRIPT_DIR/init-scripts/01-init-database.sql" ]; then
echo -e "${GREEN}OK - Existe init-scripts/01-init-database.sql${NC}"
elif [ -f "$SCRIPT_DIR/ddl/00-init.sql" ]; then
echo -e "${GREEN}OK - Existe ddl/00-init.sql${NC}"
else
echo -e "${RED}ERROR: No existe archivo de inicializacion${NC}"
echo -e "${YELLOW} Solucion: Crear init-scripts/01-init-database.sql${NC}"
VIOLATIONS=$((VIOLATIONS + 1))
fi
echo ""
# =============================================================================
# RESUMEN
# =============================================================================
echo -e "${BLUE}=============================================================================${NC}"
if [ "$VIOLATIONS" -eq 0 ]; then
echo -e "${GREEN} POLITICA DE CARGA LIMPIA: CUMPLIDA${NC}"
echo -e "${GREEN}=============================================================================${NC}"
echo -e "${GREEN} Todas las validaciones pasaron correctamente${NC}"
echo -e "${GREEN}=============================================================================${NC}"
exit 0
else
echo -e "${RED} POLITICA DE CARGA LIMPIA: VIOLADA${NC}"
echo -e "${RED}=============================================================================${NC}"
echo -e "${RED} Se encontraron $VIOLATIONS violacion(es)${NC}"
echo -e "${RED} Revisar DIRECTIVA-POLITICA-CARGA-LIMPIA.md para corregir${NC}"
echo -e "${RED}=============================================================================${NC}"
exit 1
fi