Shuffle/.claude/hooks/protect-migrations.sh
cschlaefke 317634dac5
Some checks are pending
CI / flutter (push) Waiting to run
CI / supabase (push) Waiting to run
CI / supabase-tests (push) Waiting to run
chore: initial project kit
2026-11-02 12:14:09 +01:00

14 lines
596 B
Bash
Executable file

#!/usr/bin/env bash
# Verhindert, dass bereits committete Supabase-Migrationen verändert werden.
# Neue (noch nicht in git bekannte) Migrationen sind erlaubt.
set -euo pipefail
file=$(jq -r '.tool_input.file_path // empty')
[[ "$file" == */supabase/migrations/*.sql ]] || exit 0
cd "${CLAUDE_PROJECT_DIR:-.}"
if git ls-files --error-unmatch "$file" >/dev/null 2>&1; then
echo "Bestehende Migration $file darf nicht geändert werden. Lege eine neue Migration an (supabase migration new <name>)." >&2
exit 2 # Exit 2 blockiert den Tool-Aufruf; die Meldung geht an Claude zurück
fi
exit 0