All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 2m11s
25 lines
683 B
TypeScript
25 lines
683 B
TypeScript
import { config } from "dotenv";
|
|
import { drizzle } from "drizzle-orm/node-postgres";
|
|
import { migrate } from "drizzle-orm/node-postgres/migrator";
|
|
import { Pool } from "pg";
|
|
import { resolve, dirname } from "path";
|
|
import { fileURLToPath } from "url";
|
|
|
|
config({
|
|
path: resolve(dirname(fileURLToPath(import.meta.url)), "../../../.env"),
|
|
});
|
|
|
|
const pool = new Pool({ connectionString: process.env["DATABASE_URL"]! });
|
|
const db = drizzle(pool);
|
|
|
|
console.log("starting database migrations...");
|
|
|
|
await migrate(db, {
|
|
migrationsFolder: resolve(
|
|
dirname(fileURLToPath(import.meta.url)),
|
|
"../../drizzle",
|
|
),
|
|
});
|
|
|
|
await pool.end();
|
|
console.log("database migrations complete.");
|