@biffo/cli 0.424.0 → 0.425.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/pg-test-db.sh +28 -8
package/package.json
CHANGED
package/scripts/pg-test-db.sh
CHANGED
|
@@ -253,13 +253,33 @@ if [ -z "$DDL_FILES" ] && [ -z "$ALEMBIC_DIR" ]; then
|
|
|
253
253
|
exit 1
|
|
254
254
|
fi
|
|
255
255
|
|
|
256
|
-
# PostGIS or plain, decided by what the DDL asks for. A plain
|
|
257
|
-
# fails on the first `CREATE EXTENSION postgis
|
|
258
|
-
# unconditionally would slow every repo that does
|
|
259
|
-
|
|
260
|
-
|
|
256
|
+
# PostGIS, pgvector or plain, decided by what the DDL asks for. A plain
|
|
257
|
+
# `postgres` image fails on the first `CREATE EXTENSION postgis` (or `vector`),
|
|
258
|
+
# and picking a heavier image unconditionally would slow every repo that does
|
|
259
|
+
# not need it. No single stock image carries both extensions, so DDL asking for
|
|
260
|
+
# both is an explicit failure naming the override rather than a guess.
|
|
261
|
+
_ext_re() {
|
|
262
|
+
printf '%s' "EXTENSION[[:space:]]+(IF[[:space:]]+NOT[[:space:]]+EXISTS[[:space:]]+)?[\"]?$1[\"]?([^[:alnum:]_]|\$)"
|
|
263
|
+
}
|
|
264
|
+
_wants_ext() {
|
|
265
|
+
[ -n "$DDL_FILES" ] &&
|
|
266
|
+
echo "$DDL_FILES" | xargs grep -liE "$(_ext_re "$1")" >/dev/null 2>&1
|
|
267
|
+
}
|
|
268
|
+
_want_postgis=0
|
|
269
|
+
_want_vector=0
|
|
270
|
+
_wants_ext postgis && _want_postgis=1
|
|
271
|
+
_wants_ext vector && _want_vector=1
|
|
272
|
+
if [ -n "${BIFFO_PG_IMAGE:-}" ]; then
|
|
273
|
+
IMAGE="$BIFFO_PG_IMAGE"
|
|
274
|
+
elif [ "$_want_postgis" = 1 ] && [ "$_want_vector" = 1 ]; then
|
|
275
|
+
say "the DDL requests both the postgis and vector extensions and no single stock image provides both; build or choose an image that does and set BIFFO_PG_IMAGE to it"
|
|
276
|
+
exit 1
|
|
277
|
+
elif [ "$_want_postgis" = 1 ]; then
|
|
278
|
+
IMAGE="postgis/postgis:16-3.4"
|
|
279
|
+
elif [ "$_want_vector" = 1 ]; then
|
|
280
|
+
IMAGE="pgvector/pgvector:pg16"
|
|
261
281
|
else
|
|
262
|
-
IMAGE="
|
|
282
|
+
IMAGE="postgres:16"
|
|
263
283
|
fi
|
|
264
284
|
|
|
265
285
|
export PGPASSWORD="$PASS"
|
|
@@ -440,9 +460,9 @@ if [ "$BIFFO_PG_REAP_HOURS" -gt 0 ] 2>/dev/null && command -v docker >/dev/null
|
|
|
440
460
|
while read -r _c _img; do
|
|
441
461
|
[ "$_c" = "$CONTAINER" ] && continue
|
|
442
462
|
case "$_reapable_flat" in *" $_c "*) continue ;; esac
|
|
443
|
-
#
|
|
463
|
+
# The images this script can choose (see IMAGE above), matched by
|
|
444
464
|
# repository rather than tag so a BIFFO_PG_IMAGE override still lands.
|
|
445
|
-
case "$_img" in postgres:* | postgis/*) ;; *) continue ;; esac
|
|
465
|
+
case "$_img" in postgres:* | postgis/* | pgvector/*) ;; *) continue ;; esac
|
|
446
466
|
_made=$(docker inspect -f '{{.Created}}' "$_c" 2>/dev/null | cut -c1-19)
|
|
447
467
|
[ -z "$_made" ] && continue
|
|
448
468
|
awk -v a="$_made" -v b="$_reap_cutoff" 'BEGIN { exit !(a < b) }' &&
|