Files
cve-dashboard/scripts/reset-and-migrate.sh

38 lines
1.2 KiB
Bash
Raw Permalink Normal View History

#!/bin/bash
# =============================================================================
# reset-and-migrate.sh — Drop all Postgres data and re-run the migration
# =============================================================================
# Use this when the migration partially failed and you need a clean slate.
# Safe to run multiple times — it always starts fresh.
#
# What this does:
# 1. Drops and recreates the public schema (wipes all tables)
# 2. Runs the migration script (recreates schema + copies SQLite data)
#
# Usage:
# chmod +x scripts/reset-and-migrate.sh
# ./scripts/reset-and-migrate.sh
# =============================================================================
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
cd "$PROJECT_DIR"
echo ""
echo "── Resetting Postgres database ──"
PGPASSWORD=sV4xmC9xAUCFop0ypxMVS056QgPqGrX psql -h localhost -p 5433 -U steam -d cve_dashboard -c "
DROP SCHEMA public CASCADE;
CREATE SCHEMA public;
"
echo "✓ Schema dropped and recreated"
echo ""
echo "── Running migration ──"
node backend/scripts/migrate-to-postgres.js
echo ""
echo "✓ Done. Postgres is ready."