mirror of
https://github.com/LukeHagar/dokploy.git
synced 2025-12-11 04:19:48 +00:00
feat: add migrate file to run the migrations trought the npm command
This commit is contained in:
20
migration.ts
Normal file
20
migration.ts
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import { drizzle } from "drizzle-orm/postgres-js";
|
||||||
|
import { migrate } from "drizzle-orm/postgres-js/migrator";
|
||||||
|
import postgres from "postgres";
|
||||||
|
|
||||||
|
const connectionString = process.env.DATABASE_URL || "";
|
||||||
|
|
||||||
|
const sql = postgres(connectionString, { max: 1 });
|
||||||
|
const db = drizzle(sql);
|
||||||
|
|
||||||
|
await migrate(db, { migrationsFolder: "drizzle" })
|
||||||
|
.then(() => {
|
||||||
|
console.log("Migration complete");
|
||||||
|
sql.end();
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.log("Migration failed", error);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
sql.end();
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user