forked from syntaxbullet/AuroraBot-discord
refactor: switch Drizzle ORM from postgres-js to bun-sql driver.
This commit is contained in:
@@ -1,14 +1,13 @@
|
|||||||
import { drizzle } from "drizzle-orm/postgres-js";
|
import { drizzle } from "drizzle-orm/bun-sql";
|
||||||
import postgres from "postgres";
|
import { SQL } from "bun";
|
||||||
import * as schema from "@db/schema";
|
import * as schema from "@db/schema";
|
||||||
import { env } from "@lib/env";
|
import { env } from "@lib/env";
|
||||||
|
|
||||||
const connectionString = env.DATABASE_URL;
|
const connectionString = env.DATABASE_URL;
|
||||||
// Disable prefetch as it is not supported by "transaction" method
|
export const postgres = new SQL(connectionString);
|
||||||
export const client = postgres(connectionString, { prepare: false });
|
|
||||||
|
|
||||||
export const DrizzleClient = drizzle(client, { schema });
|
export const DrizzleClient = drizzle(postgres, { schema });
|
||||||
|
|
||||||
export const closeDatabase = async () => {
|
export const closeDatabase = async () => {
|
||||||
await client.end();
|
await postgres.close();
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user