Summary
vortex-fetch-db resolves its output directory differently for the primary DB and for indexed DBs (VORTEX_DB_INDEX=N), and the difference silently drops a plain VORTEX_DB_DIR for indexed fetches.
- Primary (
VORTEX_DB_INDEX unset): dir resolves VORTEX_FETCH_DB_DIR → VORTEX_DB_DIR → ./.data.
- Indexed (
VORTEX_DB_INDEX=2): dir resolves VORTEX_FETCH_DB2_DIR → VORTEX_DB2_DIR → ./.data.
Because the index is interpolated into the variable name (VORTEX_DB${index}_DIR), a plain VORTEX_DB_DIR that a caller exports as a base directory is honoured for the primary DB but silently ignored for indexed DBs. The same applies to the -url (and other source) resolvers.
Impact
A multi-DB setup that fetches a second database and exports VORTEX_DB_DIR (reasonably expecting it to apply to all fetches) gets the indexed DB written to ./.data instead of the requested directory. If a later step reads the indexed DB from VORTEX_DB_DIR, the file is "not found".
Concrete case - a consumer .lagoon.yml fetches the migration DB and then provisions:
- run:
name: Fetch migration database
command: |
export VORTEX_DB_DIR=/tmp/data
VORTEX_DB_INDEX=2 ./vendor/bin/vortex-fetch-db # writes db2.sql to ./.data, not /tmp/data
- run:
name: Provision site
command: |
export VORTEX_DB_DIR=/tmp/data
./vendor/bin/vortex-provision # reads db2 from /tmp/data -> not found
The deploy fails with a missing migration DB file. It only surfaces on environments that override VORTEX_DB_DIR (e.g. Lagoon, which uses /tmp/data); CI defaults everything to ./.data, so both the fetch and the read agree there and the bug is masked. Current workaround: also export VORTEX_DB2_DIR=/tmp/data.
Suggested fix
Let the non-indexed base variable act as a global fallback for indexed fetches, so VORTEX_DB_DIR applies to every index unless a per-index VORTEX_DB<N>_DIR (or VORTEX_FETCH_DB<N>_DIR) overrides it. In src/vortex-fetch-db:
_v="VORTEX_FETCH_DB${_db_index}_DIR"
_vs="VORTEX_DB${_db_index}_DIR"
VORTEX_FETCH_DB_DIR="${!_v:-${!_vs:-${VORTEX_DB_DIR:-./.data}}}"
and the equivalent in the source-specific resolvers (vortex-fetch-db-url, etc.). This keeps per-index overrides working while making a plain VORTEX_DB_DIR a predictable base directory for all fetches, which is what the primary-DB behaviour already implies.
Version: drevops/vortex-tooling 1.3.0.
Summary
vortex-fetch-dbresolves its output directory differently for the primary DB and for indexed DBs (VORTEX_DB_INDEX=N), and the difference silently drops a plainVORTEX_DB_DIRfor indexed fetches.VORTEX_DB_INDEXunset): dir resolvesVORTEX_FETCH_DB_DIR→VORTEX_DB_DIR→./.data.VORTEX_DB_INDEX=2): dir resolvesVORTEX_FETCH_DB2_DIR→VORTEX_DB2_DIR→./.data.Because the index is interpolated into the variable name (
VORTEX_DB${index}_DIR), a plainVORTEX_DB_DIRthat a caller exports as a base directory is honoured for the primary DB but silently ignored for indexed DBs. The same applies to the-url(and other source) resolvers.Impact
A multi-DB setup that fetches a second database and exports
VORTEX_DB_DIR(reasonably expecting it to apply to all fetches) gets the indexed DB written to./.datainstead of the requested directory. If a later step reads the indexed DB fromVORTEX_DB_DIR, the file is "not found".Concrete case - a consumer
.lagoon.ymlfetches the migration DB and then provisions:The deploy fails with a missing migration DB file. It only surfaces on environments that override
VORTEX_DB_DIR(e.g. Lagoon, which uses/tmp/data); CI defaults everything to./.data, so both the fetch and the read agree there and the bug is masked. Current workaround: alsoexport VORTEX_DB2_DIR=/tmp/data.Suggested fix
Let the non-indexed base variable act as a global fallback for indexed fetches, so
VORTEX_DB_DIRapplies to every index unless a per-indexVORTEX_DB<N>_DIR(orVORTEX_FETCH_DB<N>_DIR) overrides it. Insrc/vortex-fetch-db:and the equivalent in the source-specific resolvers (
vortex-fetch-db-url, etc.). This keeps per-index overrides working while making a plainVORTEX_DB_DIRa predictable base directory for all fetches, which is what the primary-DB behaviour already implies.Version:
drevops/vortex-tooling1.3.0.