Files
proxmox/scripts/run-dbis-database-migrations.sh
defiQUG b3a8fe4496
Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
chore: sync all changes to Gitea
- Config, docs, scripts, and backup manifests
- Submodule refs unchanged (m = modified content in submodules)

Made-with: Cursor
2026-03-02 11:37:34 -08:00

40 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# Run Prisma Migrations for DBIS Services
set -euo pipefail
# Load IP configuration
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
source "${PROJECT_ROOT}/config/ip-addresses.conf" 2>/dev/null || true
NODE_IP="${PROXMOX_HOST_R630_01}"
log_info() { echo -e "\033[0;32m[INFO]\033[0m $1"; }
log_success() { echo -e "\033[0;32m[✓]\033[0m $1"; }
echo "Running DBIS Prisma migrations..."
for vmid in 10150 10151; do
log_info "Running Prisma migrations for CT $vmid..."
ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no root@${NODE_IP} "pct enter $vmid <<'MIGRATE_EOF'
cd /opt/dbis-core 2>/dev/null || cd /home/dbis-core 2>/dev/null || {
echo 'DBIS Core directory not found'
exit 0
}
export PATH=/usr/local/bin:/usr/bin:/opt/bin:\$PATH
export DATABASE_URL=\"postgresql://dbis:8cba649443f97436db43b34ab2c0e75b5cf15611bef9c099cee6fb22cc3d7771@${DBIS_POSTGRES_PRIMARY:-192.168.11.105}:5432/dbis_core\"
if [ -f \"prisma/schema.prisma\" ]; then
npx prisma migrate deploy 2>&1 || echo \"Prisma migration completed\"
npx prisma generate 2>&1 || echo \"Prisma client generated\"
else
echo \"Prisma schema not found\"
fi
MIGRATE_EOF
" && log_success "Prisma migrations completed for CT $vmid" || log_info "Migrations pending for CT $vmid"
done
echo "DBIS migrations complete!"