Some checks are pending
CI Pipeline / changes (push) Waiting to run
CI Pipeline / core (push) Blocked by required conditions
CI Pipeline / trading-backend (push) Blocked by required conditions
CI Pipeline / trading-data-service (push) Blocked by required conditions
CI Pipeline / trading-frontend (push) Blocked by required conditions
CI Pipeline / erp-core (push) Blocked by required conditions
CI Pipeline / erp-mecanicas (push) Blocked by required conditions
CI Pipeline / gamilit-backend (push) Blocked by required conditions
CI Pipeline / gamilit-frontend (push) Blocked by required conditions
Gamilit: - Backend: Teacher services, assignments, gamification, exercise submissions - Frontend: Admin/Teacher/Student portals, module 4-5 mechanics, monitoring - Database: DDL functions, seeds for dev/prod, auth/gamification schemas - Docs: Architecture, features, guides cleanup and reorganization Core/Orchestration: - New workspace directives index - Documentation directive Trading-platform: - Database seeds and inventory updates - Tech leader validation report 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
117 lines
2.8 KiB
Bash
Executable File
117 lines
2.8 KiB
Bash
Executable File
#!/bin/bash
|
|
# ============================================================================
|
|
# OrbiQuant IA - Trading Platform
|
|
# Script: load-seeds.sh
|
|
# Description: Load database seeds for development or production
|
|
# ============================================================================
|
|
# Usage:
|
|
# ./load-seeds.sh dev # Load development seeds
|
|
# ./load-seeds.sh prod # Load production seeds
|
|
# ============================================================================
|
|
|
|
set -e
|
|
|
|
# Colores
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m' # No Color
|
|
|
|
# Configuración por defecto
|
|
ENV=${1:-dev}
|
|
DB_HOST=${DB_HOST:-localhost}
|
|
DB_PORT=${DB_PORT:-5432}
|
|
DB_NAME=${DB_NAME:-orbiquant_trading}
|
|
DB_USER=${DB_USER:-orbiquant_user}
|
|
|
|
# Directorio base
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
SEEDS_DIR="$SCRIPT_DIR/$ENV"
|
|
|
|
echo -e "${BLUE}============================================${NC}"
|
|
echo -e "${BLUE} OrbiQuant IA - Seed Loader${NC}"
|
|
echo -e "${BLUE}============================================${NC}"
|
|
echo ""
|
|
|
|
# Verificar ambiente
|
|
if [ ! -d "$SEEDS_DIR" ]; then
|
|
echo -e "${RED}Error: Environment '$ENV' not found${NC}"
|
|
echo -e "Available environments: dev, prod"
|
|
exit 1
|
|
fi
|
|
|
|
echo -e "${YELLOW}Environment: $ENV${NC}"
|
|
echo -e "${YELLOW}Database: $DB_NAME@$DB_HOST:$DB_PORT${NC}"
|
|
echo ""
|
|
|
|
# Función para ejecutar SQL
|
|
execute_sql() {
|
|
local file=$1
|
|
local name=$(basename "$file")
|
|
|
|
if PGPASSWORD=$DB_PASSWORD psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d "$DB_NAME" -f "$file" > /dev/null 2>&1; then
|
|
echo -e " ${GREEN}✓${NC} $name"
|
|
return 0
|
|
else
|
|
echo -e " ${RED}✗${NC} $name"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
# Orden de carga de seeds
|
|
SEED_ORDER=(
|
|
"auth"
|
|
"trading"
|
|
"investment"
|
|
"financial"
|
|
"education"
|
|
"ml"
|
|
)
|
|
|
|
# Contadores
|
|
TOTAL=0
|
|
SUCCESS=0
|
|
FAILED=0
|
|
|
|
# Procesar cada schema en orden
|
|
for schema in "${SEED_ORDER[@]}"; do
|
|
schema_dir="$SEEDS_DIR/$schema"
|
|
|
|
if [ -d "$schema_dir" ]; then
|
|
sql_files=$(find "$schema_dir" -name "*.sql" | sort)
|
|
|
|
if [ -n "$sql_files" ]; then
|
|
echo -e "${BLUE}Loading $schema seeds...${NC}"
|
|
|
|
for sql_file in $sql_files; do
|
|
((TOTAL++))
|
|
if execute_sql "$sql_file"; then
|
|
((SUCCESS++))
|
|
else
|
|
((FAILED++))
|
|
fi
|
|
done
|
|
echo ""
|
|
fi
|
|
fi
|
|
done
|
|
|
|
# Resumen
|
|
echo -e "${BLUE}============================================${NC}"
|
|
echo -e "${BLUE} Summary${NC}"
|
|
echo -e "${BLUE}============================================${NC}"
|
|
echo -e " Total files: $TOTAL"
|
|
echo -e " ${GREEN}Success: $SUCCESS${NC}"
|
|
if [ $FAILED -gt 0 ]; then
|
|
echo -e " ${RED}Failed: $FAILED${NC}"
|
|
fi
|
|
echo ""
|
|
|
|
if [ $FAILED -gt 0 ]; then
|
|
echo -e "${RED}Some seeds failed to load. Check the logs above.${NC}"
|
|
exit 1
|
|
else
|
|
echo -e "${GREEN}All seeds loaded successfully!${NC}"
|
|
fi
|