31 lines
791 B
TypeScript
31 lines
791 B
TypeScript
/**
|
|
* Exécute les migrations Drizzle pendantes.
|
|
*
|
|
* DATABASE_URL=postgres://... pnpm --filter @ordinarthur-os/db migrate
|
|
*/
|
|
import * as path from "node:path";
|
|
import { migrate } from "drizzle-orm/postgres-js/migrator";
|
|
import { createDb } from "./client";
|
|
|
|
async function main() {
|
|
const url = process.env.DATABASE_URL;
|
|
if (!url) {
|
|
console.error("[migrate] DATABASE_URL manquant");
|
|
process.exit(1);
|
|
}
|
|
|
|
const { db, close } = createDb(url);
|
|
try {
|
|
console.log("[migrate] application des migrations…");
|
|
await migrate(db, { migrationsFolder: path.resolve(__dirname, "..", "migrations") });
|
|
console.log("[migrate] ✓ à jour");
|
|
} finally {
|
|
await close();
|
|
}
|
|
}
|
|
|
|
main().catch((err) => {
|
|
console.error("[migrate] échec:", err);
|
|
process.exit(1);
|
|
});
|