mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-07-07 23:15:27 +02:00
refactor: rename builders to server
This commit is contained in:
20
packages/server/src/db/index.ts
Normal file
20
packages/server/src/db/index.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { type PostgresJsDatabase, drizzle } from "drizzle-orm/postgres-js";
|
||||
import postgres from "postgres";
|
||||
import * as schema from "./schema";
|
||||
declare global {
|
||||
var db: PostgresJsDatabase<typeof schema> | undefined;
|
||||
}
|
||||
|
||||
export let db: PostgresJsDatabase<typeof schema>;
|
||||
if (process.env.NODE_ENV === "production") {
|
||||
db = drizzle(postgres(process.env.DATABASE_URL || ""), {
|
||||
schema,
|
||||
});
|
||||
} else {
|
||||
if (!global.db)
|
||||
global.db = drizzle(postgres(process.env.DATABASE_URL || ""), {
|
||||
schema,
|
||||
});
|
||||
|
||||
db = global.db;
|
||||
}
|
||||
Reference in New Issue
Block a user