mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-07-11 05:24:59 +10:00
99c602e3c7
* Migrate from Biome to Oxlint/Oxfmt * pin version of autofix * set version of autofix * pin version of autofix * [autofix.ci] apply automated fixes * better comments, test formatter * [autofix.ci] apply automated fixes * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
35 lines
943 B
TypeScript
35 lines
943 B
TypeScript
import { sql } from "drizzle-orm";
|
|
import { drizzle } from "drizzle-orm/node-postgres";
|
|
import { Pool } from "pg";
|
|
|
|
import { env } from "@/utils/env";
|
|
|
|
export async function resetDatabase() {
|
|
console.log("⌛ Resetting database...");
|
|
|
|
const pool = new Pool({ connectionString: env.DATABASE_URL });
|
|
const db = drizzle({ client: pool });
|
|
|
|
try {
|
|
await db.transaction(async (tx) => {
|
|
await tx.execute(sql`DROP SCHEMA drizzle CASCADE`);
|
|
await tx.execute(sql`CREATE SCHEMA drizzle`);
|
|
await tx.execute(sql`GRANT ALL ON SCHEMA drizzle TO postgres`);
|
|
|
|
await tx.execute(sql`DROP SCHEMA public CASCADE`);
|
|
await tx.execute(sql`CREATE SCHEMA public`);
|
|
await tx.execute(sql`GRANT ALL ON SCHEMA public TO postgres`);
|
|
});
|
|
|
|
console.log("✅ Database reset completed");
|
|
} catch (error) {
|
|
console.error("🚨 Database reset failed:", error);
|
|
} finally {
|
|
await pool.end();
|
|
}
|
|
}
|
|
|
|
if (import.meta.main) {
|
|
await resetDatabase();
|
|
}
|