@biffo/cli 0.397.0 → 0.398.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 +27 -4
- package/scripts/verify.sh +0 -7
package/package.json
CHANGED
package/scripts/pg-test-db.sh
CHANGED
|
@@ -213,7 +213,30 @@ cd "$REPO_ROOT"
|
|
|
213
213
|
# `ddl_import.list_sql_files` reads at startup, so deriving from it means this
|
|
214
214
|
# script and the running app agree by construction rather than by someone
|
|
215
215
|
# remembering to update both.
|
|
216
|
-
|
|
216
|
+
#
|
|
217
|
+
# The apply ORDER comes from the same place: `api/ddl_order.py`, run as a plain
|
|
218
|
+
# script. Numbered modules go first by name, unnumbered `<slug>.sql` modules
|
|
219
|
+
# after them in merge order, derived from git history (biffo-template#2458).
|
|
220
|
+
# A repo without that file (a plugin, or an instance not yet upgraded) keeps
|
|
221
|
+
# name order, which is only right while an import has at most one unnumbered
|
|
222
|
+
# module (a plugin's single `schema.sql`), so two there stop the build rather
|
|
223
|
+
# than applying out of order.
|
|
224
|
+
DDL_ORDER_SCRIPT=services/api/src/api/ddl_order.py
|
|
225
|
+
DDL_DIRS=$(find db/imports -mindepth 1 -maxdepth 1 -type d 2>/dev/null | LC_ALL=C sort || true)
|
|
226
|
+
DDL_FILES=""
|
|
227
|
+
if [ -n "$DDL_DIRS" ] && [ -f "$DDL_ORDER_SCRIPT" ]; then
|
|
228
|
+
# shellcheck disable=SC2086 # one argument per import directory
|
|
229
|
+
DDL_FILES=$(python3 "$DDL_ORDER_SCRIPT" $DDL_DIRS) || {
|
|
230
|
+
say "could not derive the DDL apply order (see the ddl_order message above)"
|
|
231
|
+
exit 1
|
|
232
|
+
}
|
|
233
|
+
elif [ -n "$DDL_DIRS" ]; then
|
|
234
|
+
DDL_FILES=$(find db/imports -mindepth 2 -maxdepth 2 -name '*.sql' 2>/dev/null | LC_ALL=C sort || true)
|
|
235
|
+
if echo "$DDL_FILES" | grep '/[^/0-9][^/]*$' | sed 's|/[^/]*$||' | uniq -d | grep -q .; then
|
|
236
|
+
say "an import in db/imports/ holds several unnumbered modules but $DDL_ORDER_SCRIPT is absent, so their apply order cannot be derived"
|
|
237
|
+
exit 1
|
|
238
|
+
fi
|
|
239
|
+
fi
|
|
217
240
|
ALEMBIC_DIR=""
|
|
218
241
|
for _d in services/api .; do
|
|
219
242
|
[ -f "$_d/alembic.ini" ] && ALEMBIC_DIR="$_d" && break
|
|
@@ -688,11 +711,11 @@ fi
|
|
|
688
711
|
|
|
689
712
|
_module_count=0
|
|
690
713
|
if [ -n "$DDL_FILES" ]; then
|
|
691
|
-
# ONE psql session,
|
|
714
|
+
# ONE psql session, in apply order, mirroring the API's own DDL import.
|
|
692
715
|
# Session state an early module sets -- typically `SET search_path` in the
|
|
693
716
|
# first file -- has to survive into later ones, so a per-file connection would
|
|
694
|
-
# silently change the meaning of every unqualified name after it.
|
|
695
|
-
#
|
|
717
|
+
# silently change the meaning of every unqualified name after it. The order
|
|
718
|
+
# is DDL_FILES' own (see "what this repo's schema is made of" above).
|
|
696
719
|
# shellcheck disable=SC2046
|
|
697
720
|
psql -q -v ON_ERROR_STOP=1 -h "$HOST" -p "$PORT" -U "$USER_" -d "$DB" \
|
|
698
721
|
--single-transaction $(echo "$DDL_FILES" | sed 's/^/-f /' | tr '\n' ' ') >/dev/null
|
package/scripts/verify.sh
CHANGED
|
@@ -1671,13 +1671,6 @@ fi
|
|
|
1671
1671
|
[ -f scripts/plugin-staleness-target-repo.test.sh ] &&
|
|
1672
1672
|
run_check plugin-staleness-target-repo sh scripts/plugin-staleness-target-repo.test.sh
|
|
1673
1673
|
|
|
1674
|
-
# The DDL module-number allocator's own race-freedom proof (#1886): races real
|
|
1675
|
-
# `git` processes against throwaway local bare repos (never a mock of git, and
|
|
1676
|
-
# never /tmp -- repo-local scratch dirs cleaned up by its own trap), so it needs
|
|
1677
|
-
# neither network nor a live deployment. Measured here: ~2.4s.
|
|
1678
|
-
[ -f scripts/allocate-module-number.test.sh ] &&
|
|
1679
|
-
run_check allocate-module-number sh scripts/allocate-module-number.test.sh
|
|
1680
|
-
|
|
1681
1674
|
# check-orphan-ratchet-instance.sh's own self-test (#1714, second
|
|
1682
1675
|
# remediation): real throwaway git fixtures standing in for "the template at
|
|
1683
1676
|
# a pinned version" and "a live instance", exercising the wrapper end to end
|