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
+47
View File
@@ -0,0 +1,47 @@
#!/bin/bash
# Usage: SUPABASE_DB_URL="postgresql://postgres:..." bash db/05-verify.sh
set -e
SERVER="setia@ims.setia.com.my"
PORT=9321
echo "=== IMS Data Migration Verification ==="
echo ""
echo "--- Table row counts on NEW server ---"
ssh -p "$PORT" "$SERVER" "sudo -u postgres psql -d ims" <<'ENDSQL'
SELECT
tablename,
n_live_tup AS row_count
FROM pg_stat_user_tables
ORDER BY tablename;
ENDSQL
if [ -n "$SUPABASE_DB_URL" ]; then
echo ""
echo "--- Table row counts on SUPABASE (source) ---"
psql "$SUPABASE_DB_URL" <<'ENDSQL'
SELECT
tablename,
n_live_tup AS row_count
FROM pg_stat_user_tables
WHERE schemaname = 'public'
ORDER BY tablename;
ENDSQL
fi
echo ""
echo "--- Users with NULL password_hash (should be 0) ---"
ssh -p "$PORT" "$SERVER" "sudo -u postgres psql -d ims -c \"SELECT count(*) FROM users WHERE password_hash IS NULL;\""
echo ""
echo "--- Evidence files row count vs filesystem count ---"
ssh -p "$PORT" "$SERVER" "sudo -u postgres psql -d ims -c \"SELECT count(*) AS db_evidence_rows FROM evidence_files WHERE deleted = false;\""
ssh -p "$PORT" "$SERVER" "find /var/lib/ims/evidence -type f | wc -l"
echo ""
echo "--- pgvector embeddings check ---"
ssh -p "$PORT" "$SERVER" "sudo -u postgres psql -d ims -c \"SELECT count(*) AS incidents_with_embedding FROM incidents WHERE embedding IS NOT NULL;\""
echo ""
echo "=== Verification complete. Compare counts above. ==="