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,
|
"private": true,
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/bun": "latest",
|
"@types/bun": "latest",
|
||||||
"drizzle-kit": "^0.31.7",
|
"drizzle-kit": "^0.31.7"
|
||||||
"postgres": "^3.4.7"
|
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"typescript": "^5"
|
"typescript": "^5"
|
||||||
@@ -26,6 +25,7 @@
|
|||||||
"discord.js": "^14.25.1",
|
"discord.js": "^14.25.1",
|
||||||
"dotenv": "^17.2.3",
|
"dotenv": "^17.2.3",
|
||||||
"drizzle-orm": "^0.44.7",
|
"drizzle-orm": "^0.44.7",
|
||||||
|
"postgres": "^3.4.7",
|
||||||
"zod": "^4.1.13"
|
"zod": "^4.1.13"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,14 @@
|
|||||||
import { drizzle } from "drizzle-orm/bun-sql";
|
import { drizzle } from "drizzle-orm/postgres-js";
|
||||||
import { SQL } from "bun";
|
import postgres from "postgres";
|
||||||
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;
|
||||||
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 () => {
|
export const closeDatabase = async () => {
|
||||||
await postgres.close();
|
await client.end();
|
||||||
};
|
};
|
||||||
@@ -40,7 +40,7 @@ export class CommandLoader {
|
|||||||
continue;
|
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);
|
await this.loadCommandFile(filePath, reload, result);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user