db-init: init BASE_INSTALLED= for set -u safety

This commit is contained in:
2026-04-28 13:52:55 +00:00
parent 32d114e46a
commit aaf027b15f

View File

@@ -84,6 +84,15 @@ spec:
# check below skips the odoo step when base is already # check below skips the odoo step when base is already
# installed — fresh deploys still bootstrap correctly # installed — fresh deploys still bootstrap correctly
# because base isn't installed in a brand-new database. # because base isn't installed in a brand-new database.
# Init both vars to "" so `set -u` doesn't crash when
# the schema query returns nothing (fresh DB case —
# ir_module_module doesn't exist yet, so the inner
# query block is skipped, leaving BASE_INSTALLED
# unset). Without this, db-init crashlooped on every
# fresh deploy with: "BASE_INSTALLED: parameter not
# set".
IS_INIT=""
BASE_INSTALLED=""
IS_INIT=$(PGPASSWORD="$PASSWORD" psql -h "$HOST" -p "$PORT" -U "$USER" -d "$DBNAME" -tAc \ IS_INIT=$(PGPASSWORD="$PASSWORD" psql -h "$HOST" -p "$PORT" -U "$USER" -d "$DBNAME" -tAc \
"SELECT 1 FROM information_schema.tables WHERE table_schema='public' AND table_name='ir_module_module'" 2>/dev/null || true) "SELECT 1 FROM information_schema.tables WHERE table_schema='public' AND table_name='ir_module_module'" 2>/dev/null || true)
if [ "$IS_INIT" = "1" ]; then if [ "$IS_INIT" = "1" ]; then