initial commit

This commit is contained in:
Josh Myers
2026-04-09 20:36:10 -07:00
commit 4681b1a3c8
248 changed files with 97032 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
#!/usr/bin/env node
/**
* Migration runner for new module tables.
* Run from project root: node scripts/migrate-new-modules.js
*
* Alternative: npx prisma db push (which reads from schema.prisma)
*/
const { PrismaClient } = require('@prisma/client');
const fs = require('fs');
const path = require('path');
async function main() {
const prisma = new PrismaClient();
try {
console.log('Connecting to database...');
await prisma.$connect();
console.log('Connected.');
const sqlPath = path.join(__dirname, '..', 'prisma', 'migrations', 'add_new_modules', 'migration.sql');
const sql = fs.readFileSync(sqlPath, 'utf-8');
// Split by semicolons and execute each statement
const statements = sql
.split(';')
.map(s => s.trim())
.filter(s => s.length > 0 && !s.startsWith('--'));
console.log(`Executing ${statements.length} SQL statements...`);
for (let i = 0; i < statements.length; i++) {
const stmt = statements[i];
try {
await prisma.$executeRawUnsafe(stmt);
console.log(` [${i + 1}/${statements.length}] OK`);
} catch (err) {
// Ignore "already exists" errors
if (err.message.includes('already exists')) {
console.log(` [${i + 1}/${statements.length}] Already exists (skipped)`);
} else {
console.error(` [${i + 1}/${statements.length}] ERROR: ${err.message}`);
}
}
}
console.log('\nMigration complete!');
console.log('Next step: run "npx prisma generate" to update the Prisma client types.');
} catch (err) {
console.error('Migration failed:', err.message);
process.exit(1);
} finally {
await prisma.$disconnect();
}
}
main();