From 907ad537e223d86198f0e92d95e7384a8423081f Mon Sep 17 00:00:00 2001 From: IK Date: Fri, 11 Sep 2026 07:58:40 +0700 Subject: [PATCH] fix: accept non-hex alembic revision ids --- deploy/test-production-bootstrap.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/deploy/test-production-bootstrap.sh b/deploy/test-production-bootstrap.sh index b1fd17c..4002738 100755 --- a/deploy/test-production-bootstrap.sh +++ b/deploy/test-production-bootstrap.sh @@ -49,7 +49,7 @@ if ! ALEMBIC_HEADS_OUTPUT=$($compose exec -T api alembic heads 2>/dev/null); the exit 1 fi # Extract revision IDs (first field before space or '(head)'), handle multiple heads -ALEMBIC_HEAD=$(echo "$ALEMBIC_HEADS_OUTPUT" | grep -oE '^[a-f0-9]+' | head -1) +ALEMBIC_HEAD=$(printf '%s\n' "$ALEMBIC_HEADS_OUTPUT" | awk 'NF {print $1; exit}') DB_VERSION=$($compose exec -T db psql -At -U rf4 -d rf4_spotter -c 'select version_num from alembic_version') if [ -z "$ALEMBIC_HEAD" ]; then @@ -63,10 +63,10 @@ if [ -z "$DB_VERSION" ]; then fi # Handle multiple heads: check if DB version matches any head -HEAD_COUNT=$(echo "$ALEMBIC_HEADS_OUTPUT" | grep -cE '^[a-f0-9]+') || HEAD_COUNT=0 +HEAD_COUNT=$(printf '%s\n' "$ALEMBIC_HEADS_OUTPUT" | awk 'NF {count++} END {print count+0}') if [ "$HEAD_COUNT" -gt 1 ]; then echo "WARNING: Multiple Alembic heads detected ($HEAD_COUNT), checking if DB version matches any..." - if ! echo "$ALEMBIC_HEADS_OUTPUT" | grep -q "^$DB_VERSION"; then + if ! printf '%s\n' "$ALEMBIC_HEADS_OUTPUT" | awk '{print $1}' | grep -Fxq "$DB_VERSION"; then echo "ERROR: DB version $DB_VERSION does not match any head. Heads: $ALEMBIC_HEADS_OUTPUT" >&2 exit 1 fi