mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-15 18:30:39 +09:00
14 lines
449 B
TypeScript
14 lines
449 B
TypeScript
|
|
import { migrate } from "drizzle-orm/postgres-js/migrator";
|
||
|
|
import postgres from "postgres";
|
||
|
|
import { drizzle } from "drizzle-orm/postgres-js";
|
||
|
|
|
||
|
|
const url = process.env.DATABASE_URL;
|
||
|
|
if (!url) throw new Error("DATABASE_URL is required");
|
||
|
|
|
||
|
|
const sql = postgres(url, { max: 1 });
|
||
|
|
const db = drizzle(sql);
|
||
|
|
|
||
|
|
await migrate(db, { migrationsFolder: new URL("./migrations", import.meta.url).pathname });
|
||
|
|
await sql.end();
|
||
|
|
console.log("Migrations complete");
|