moving to postgres, part 2

This commit is contained in:
2025-09-17 23:16:29 +02:00
parent 223add151c
commit 2862aacc50
9 changed files with 45 additions and 48 deletions

View File

@@ -1,18 +1,15 @@
import * as schema from "db/schema";
import logger from "lib/logger";
// const host = process.env.POSTGRES_HOST ?? "";
// if (!host) { logger.enverr("POSTGRES_HOST"); process.exit(1); };
//
// const user = process.env.POSTGRES_USER ?? "";
// if (!user) { logger.enverr("POSTGRES_USER"); process.exit(1); };
// const password = process.env.POSTGRES_PASSWORD ?? "";
// if (!password) { logger.enverr("POSTGRES_USER"); process.exit(1); };
// const database = process.env.POSTGRES_DB ?? "twitchbot";
//
// const connection = { host, user, password, database };
const url = `postgresql://admin:abcdefgh@localhost:5432/twitchbot`;
const host = process.env.POSTGRES_HOST ?? "";
if (!host) { logger.enverr("POSTGRES_HOST"); process.exit(1); };
const user = process.env.POSTGRES_USER ?? "";
if (!user) { logger.enverr("POSTGRES_USER"); process.exit(1); };
const password = process.env.POSTGRES_PASSWORD ?? "";
if (!password) { logger.enverr("POSTGRES_USER"); process.exit(1); };
const database = process.env.POSTGRES_DB ?? "";
if (!database) { logger.enverr("POSTGRES_DB"); process.exit(1); };
const url = `postgresql://${user}:${password}@${host}/${database}`;
import { drizzle } from 'drizzle-orm/bun-sql';
export default drizzle(url, {
schema
});
export default drizzle(url, { schema });