#!/bin/sh set -eu expected=1 for file in backend/migrations/*.up.sql; do [ -s "$file" ] || { echo 'empty migration' >&2; exit 1; } base=${file%.up.sql} [ -s "$base.down.sql" ] || { echo 'missing down migration' >&2; exit 1; } name=${base##*/} version=${name%%_*} [ "$version" = "$(printf '%06d' "$expected")" ] || { echo 'migration sequence must be contiguous and unique' >&2; exit 1; } expected=$((expected + 1)) done [ "$expected" -gt 1 ] || { echo 'no migrations found' >&2; exit 1; } for file in backend/migrations/*.down.sql; do [ -s "${file%.down.sql}.up.sql" ] || { echo 'missing up migration' >&2; exit 1; } done for file in scripts/*.sh deploy/entrypoint.sh; do sh -n "$file"; done printf '%s\n' 'Migration naming/pairs and shell syntax passed; this does not execute migrations or Compose.'