#!/usr/bin/env bash # Prints the next available Flyway version for db/migration/. set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" MIGRATION_DIR="$ROOT/backend/src/main/resources/db/migration" max=0 for file in "$MIGRATION_DIR"/V*.sql; do [[ -e "$file" ]] || continue name="$(basename "$file")" if [[ "$name" =~ ^V([0-9]+)__ ]]; then version="${BASH_REMATCH[1]}" version=$((10#$version)) if (( version > max )); then max=$version fi fi done next=$((max + 1)) echo "Next migration: V${next}__your_description.sql"