mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-07-25 15:55:43 +02:00
- Introduced migration script to handle database schema updates using Drizzle ORM. - Added truncation script to clear the database schema and reset the state. - Updated package.json scripts for easier execution of migration and truncation tasks. - Refactored email and Stripe integration for better modularity and maintainability.
23 lines
591 B
TypeScript
23 lines
591 B
TypeScript
import { drizzle } from "drizzle-orm/postgres-js";
|
|
import { migrate } from "drizzle-orm/postgres-js/migrator";
|
|
import postgres from "postgres";
|
|
import "dotenv/config";
|
|
import * as schema from "./schema";
|
|
|
|
const connectionString = process.env.DATABASE_URL!;
|
|
const sql = postgres(connectionString, { max: 1 });
|
|
const db = drizzle(sql, { schema });
|
|
|
|
await migrate(db, { migrationsFolder: "drizzle" })
|
|
.then(() => {
|
|
console.log("Migration complete");
|
|
sql.end();
|
|
})
|
|
.catch((error) => {
|
|
console.error("Migration failed", error);
|
|
process.exit(1);
|
|
})
|
|
.finally(() => {
|
|
sql.end();
|
|
});
|