initial commit of v5

This commit is contained in:
Amruth Pillai
2026-01-19 23:31:54 +01:00
parent 55bdfd0067
commit cad390fa13
1132 changed files with 200807 additions and 165288 deletions
+30
View File
@@ -0,0 +1,30 @@
import { drizzle } from "drizzle-orm/node-postgres";
import { migrate } from "drizzle-orm/node-postgres/migrator";
import { definePlugin } from "nitro";
import { Pool } from "pg";
async function migrateDatabase() {
console.log("⌛ Running database migrations...");
const connectionString = process.env.DATABASE_URL;
if (!connectionString) {
throw new Error("DATABASE_URL is not set");
}
const pool = new Pool({ connectionString });
const db = drizzle({ client: pool });
try {
await migrate(db, { migrationsFolder: "./migrations" });
console.log("✅ Database migrations completed");
} catch (error) {
console.error("🚨 Database migrations failed:", error);
} finally {
await pool.end();
}
}
export default definePlugin(async () => {
await migrateDatabase();
});