import fs from 'fs'; import pg from 'pg'; const { Pool } = pg; const pool = new Pool({ connectionString: "postgresql://app_user:Al5eVT1SJ7i4UHmSZr1F@204.168.129.249:5432/app_data", ssl: false }); const quotes = JSON.parse(fs.readFileSync('quotes.json', 'utf8')); async function migrate() { await pool.query(` CREATE TABLE IF NOT EXISTS quotes ( id SERIAL PRIMARY KEY, quote_id VARCHAR(255) UNIQUE NOT NULL, data JSONB NOT NULL ) `); for (const q of quotes) { await pool.query( 'INSERT INTO quotes (quote_id, data) VALUES ($1, $2) ON CONFLICT (quote_id) DO UPDATE SET data = $2', [String(q.id), q] ); } console.log(`Successfully migrated ${quotes.length} quotes to your new production database!`); process.exit(0); } migrate().catch(console.error);