veza/scripts/squash_migrations.sh

31 lines
811 B
Bash
Raw Permalink Normal View History

#!/bin/bash
set -euo pipefail
MIGRATIONS_DIR="veza-backend-api/migrations"
OUTPUT_FILE="veza-backend-api/migrations/baseline_v0601.sql"
{
echo "-- Baseline SQL generated from migrations 001-113"
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;"
} > "$OUTPUT_FILE"
echo "Baseline written to $OUTPUT_FILE"