Inicializar BD manualmente después del deploy
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 16s

Los scripts de init de Docker no se ejecutaban porque el bind mount
apunta a un directorio temporal del runner. Ahora ejecutamos los scripts
SQL manualmente después del deploy si las tablas no existen.
This commit is contained in:
2025-11-21 18:59:35 -06:00
parent 659819d0ae
commit 808bb0589e

View File

@@ -45,3 +45,17 @@ jobs:
docker compose pull
docker compose --project-name $APP_NAME down
docker compose --project-name $APP_NAME up -d --remove-orphans --wait
# Inicializar base de datos si es necesario
echo "🗄️ Inicializando base de datos..."
# Verificar si las tablas existen
TABLE_EXISTS=$(docker exec $APP_NAME-postgres psql -U $POSTGRES_USER -d $POSTGRES_DB -tAc "SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_name = 'lotes');")
if [ "$TABLE_EXISTS" = "f" ]; then
echo "📝 Ejecutando scripts de inicialización..."
docker exec -i $APP_NAME-postgres psql -U $POSTGRES_USER -d $POSTGRES_DB < nuxt4/server/database/01_schema.sql
docker exec -i $APP_NAME-postgres psql -U $POSTGRES_USER -d $POSTGRES_DB < nuxt4/server/database/02_seed.sql
echo "✅ Base de datos inicializada"
else
echo " Base de datos ya inicializada"
fi