fix: update drizzle config to read env vars directly for CLI compatibility
This commit is contained in:
+15
-11
@@ -1,20 +1,24 @@
|
||||
import { defineConfig } from "drizzle-kit";
|
||||
import { config } from "./src/config";
|
||||
|
||||
const databaseType = process.env.DATABASE_TYPE || "sqlite";
|
||||
const databaseUrl = process.env.DATABASE_URL;
|
||||
|
||||
export default defineConfig({
|
||||
schema: "./src/database/schema.ts",
|
||||
out: "./drizzle/migrations",
|
||||
dialect: config.DATABASE_TYPE === "postgres" ? "postgresql" : "sqlite",
|
||||
dialect: databaseType === "postgres" ? "postgresql" : "sqlite",
|
||||
dbCredentials:
|
||||
config.DATABASE_TYPE === "postgres"
|
||||
? {
|
||||
host: config.POSTGRES_HOST,
|
||||
port: config.POSTGRES_PORT,
|
||||
user: config.POSTGRES_USER || "postgres",
|
||||
password: config.POSTGRES_PASSWORD || "",
|
||||
database: config.POSTGRES_DB || "moderation_bot",
|
||||
}
|
||||
databaseType === "postgres"
|
||||
? databaseUrl
|
||||
? { url: databaseUrl }
|
||||
: {
|
||||
host: process.env.POSTGRES_HOST || "localhost",
|
||||
port: parseInt(process.env.POSTGRES_PORT || "5432", 10),
|
||||
user: process.env.POSTGRES_USER || "postgres",
|
||||
password: process.env.POSTGRES_PASSWORD || "",
|
||||
database: process.env.POSTGRES_DB || "moderation_bot",
|
||||
}
|
||||
: {
|
||||
url: "./.muxer-queue.db",
|
||||
url: "file:./.muxer-queue.db",
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user