veza/scripts/squash_migrations.sh

28 lines
750 B
Bash
Raw Normal View History

#!/bin/bash
set -euo pipefail
MIGRATIONS_DIR="veza-backend-api/migrations"
OUTPUT_FILE="veza-backend-api/migrations/baseline_v0501.sql"
echo "-- Baseline SQL generated from migrations 001-108"
echo "-- Generated on: $(date -u '+%Y-%m-%d %H:%M:%S UTC')"
echo "-- DO NOT EDIT: This file is auto-generated"
echo ""
echo "BEGIN;"
echo ""
for migration in $(ls "$MIGRATIONS_DIR"/*.sql 2>/dev/null | sort); do
basename_file=$(basename "$migration")
if [[ "$basename_file" == "baseline_"* ]]; then
continue
fi
echo "-- ============================================"
echo "-- Migration: $basename_file"
echo "-- ============================================"
cat "$migration"
echo ""
echo ""
done
echo "COMMIT;"