fix: accept non-hex alembic revision ids
This commit is contained in:
@@ -49,7 +49,7 @@ if ! ALEMBIC_HEADS_OUTPUT=$($compose exec -T api alembic heads 2>/dev/null); the
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
# Extract revision IDs (first field before space or '(head)'), handle multiple heads
|
# 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')
|
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
|
if [ -z "$ALEMBIC_HEAD" ]; then
|
||||||
@@ -63,10 +63,10 @@ if [ -z "$DB_VERSION" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Handle multiple heads: check if DB version matches any head
|
# 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
|
if [ "$HEAD_COUNT" -gt 1 ]; then
|
||||||
echo "WARNING: Multiple Alembic heads detected ($HEAD_COUNT), checking if DB version matches any..."
|
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
|
echo "ERROR: DB version $DB_VERSION does not match any head. Heads: $ALEMBIC_HEADS_OUTPUT" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user