feat(ops): phase 8 — data migration scripts + fix password_reset_tokens in schema.sql

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-07-24 06:30:34 +08:00
co-authored by Claude Sonnet 4.6
parent 04c36f9d45
commit b3811b3633
6 changed files with 247 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
#!/bin/bash
# Usage: SUPABASE_DB_URL="postgresql://postgres:..." bash db/02-dump-and-restore.sh
set -e
if [ -z "$SUPABASE_DB_URL" ]; then
echo "ERROR: SUPABASE_DB_URL not set"
exit 1
fi
SERVER="setia@ims.setia.com.my"
PORT=9321
DUMP_FILE="/tmp/ims-supabase-dump-$(date +%Y%m%d-%H%M%S).sql"
echo "==> Dumping Supabase public schema (data only)..."
pg_dump \
--data-only \
--no-owner \
--no-privileges \
--schema=public \
--exclude-table=schema_migrations \
"$SUPABASE_DB_URL" \
-f "$DUMP_FILE"
echo "==> Dump written to $DUMP_FILE ($(du -sh "$DUMP_FILE" | cut -f1))"
echo "==> Copying dump to server..."
scp -P "$PORT" "$DUMP_FILE" "$SERVER:/tmp/ims-data.sql"
echo "==> Restoring on server..."
ssh -p "$PORT" "$SERVER" "sudo -u postgres psql -d ims -f /tmp/ims-data.sql 2>&1 | tail -20"
echo "==> Cleaning up..."
ssh -p "$PORT" "$SERVER" "rm /tmp/ims-data.sql"
rm "$DUMP_FILE"
echo "==> Done. Run db/05-verify.sh to check row counts."