#!/bin/bash # Aplica todas las migraciones de supabase/migrations/ en orden de timestamp. # Uso: scripts/apply_all_migrations.sh set -e MIGRATIONS_DIR="$(dirname "$0")/../supabase/migrations" for f in $(ls "$MIGRATIONS_DIR"/*.sql | sort); do echo "Applying: $f" # -v ON_ERROR_STOP=1: sin esto, psql sigue ejecutando statements después de un # error SQL y termina con exit code 0 igual — set -e nunca vería el fallo. if docker exec -i supabase-db psql -v ON_ERROR_STOP=1 -U postgres -d postgres < "$f"; then echo "Done: $f" else echo "ERROR applying: $f" >&2 exit 1 fi done echo "All migrations applied."