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:
Executable
+36
@@ -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."
|
||||
Reference in New Issue
Block a user