AeThex-OS/script/run-migration.ts
MrPiglr d41043dfdc new file: EXPANSION_COMPLETE.md
new file:   QUICK_REFERENCE.md
	new file:   README_EXPANSION.md
	new file:   SESSION_SUMMARY.md
	new file:   VERIFICATION_CHECKLIST.md
	new file:   client/src/pages/lab.tsx
2025-12-24 00:24:40 +00:00

50 lines
1.3 KiB
TypeScript

import { readFile } from 'fs/promises';
import pg from 'pg';
import dotenv from 'dotenv';
dotenv.config();
const { Client } = pg;
async function runMigration() {
const client = new Client({
connectionString: process.env.DATABASE_URL,
});
try {
await client.connect();
console.log('Connected to database');
const sql = await readFile('./migrations/0001_new_apps_expansion.sql', 'utf-8');
// Split by statement breakpoints and execute each statement
const statements = sql
.split('--> statement-breakpoint')
.map(s => s.trim())
.filter(s => s.length > 0 && !s.startsWith('--'));
console.log(`Executing ${statements.length} statements...`);
for (const [index, statement] of statements.entries()) {
try {
await client.query(statement);
console.log(`✓ Statement ${index + 1}/${statements.length} executed`);
} catch (error: any) {
console.error(`✗ Statement ${index + 1} failed:`, error.message);
// Continue on duplicate errors
if (!error.message.includes('already exists')) {
throw error;
}
}
}
console.log('\n✅ Migration completed successfully!');
} catch (error) {
console.error('\n❌ Migration failed:', error);
process.exit(1);
} finally {
await client.end();
}
}
runMigration();