feat: Migrate Drizzle ORM to postgres.js, exclude test files from command loading, and adjust postgres dependency type.
This commit is contained in:
@@ -5,8 +5,7 @@
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"@types/bun": "latest",
|
||||
"drizzle-kit": "^0.31.7",
|
||||
"postgres": "^3.4.7"
|
||||
"drizzle-kit": "^0.31.7"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "^5"
|
||||
@@ -26,6 +25,7 @@
|
||||
"discord.js": "^14.25.1",
|
||||
"dotenv": "^17.2.3",
|
||||
"drizzle-orm": "^0.44.7",
|
||||
"postgres": "^3.4.7",
|
||||
"zod": "^4.1.13"
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,14 @@
|
||||
import { drizzle } from "drizzle-orm/bun-sql";
|
||||
import { SQL } from "bun";
|
||||
import { drizzle } from "drizzle-orm/postgres-js";
|
||||
import postgres from "postgres";
|
||||
import * as schema from "@db/schema";
|
||||
import { env } from "@lib/env";
|
||||
|
||||
const connectionString = env.DATABASE_URL;
|
||||
export const postgres = new SQL(connectionString);
|
||||
// Disable prefetch as it is not supported by "transaction" method
|
||||
export const client = postgres(connectionString, { prepare: false });
|
||||
|
||||
export const DrizzleClient = drizzle(postgres, { schema });
|
||||
export const DrizzleClient = drizzle(client, { schema });
|
||||
|
||||
export const closeDatabase = async () => {
|
||||
await postgres.close();
|
||||
await client.end();
|
||||
};
|
||||
@@ -40,7 +40,7 @@ export class CommandLoader {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!file.name.endsWith('.ts') && !file.name.endsWith('.js')) continue;
|
||||
if ((!file.name.endsWith('.ts') && !file.name.endsWith('.js')) || file.name.endsWith('.test.ts') || file.name.endsWith('.spec.ts')) continue;
|
||||
|
||||
await this.loadCommandFile(filePath, reload, result);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user