From 808bb0589e1732616e06a681672e75b4e8795eaa Mon Sep 17 00:00:00 2001 From: josedario87 Date: Fri, 21 Nov 2025 18:59:35 -0600 Subject: [PATCH] =?UTF-8?q?Inicializar=20BD=20manualmente=20despu=C3=A9s?= =?UTF-8?q?=20del=20deploy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .gitea/workflows/build-and-deploy.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.gitea/workflows/build-and-deploy.yml b/.gitea/workflows/build-and-deploy.yml index 3ed0779..62a1397 100644 --- a/.gitea/workflows/build-and-deploy.yml +++ b/.gitea/workflows/build-and-deploy.yml @@ -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