mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
refactor(database): ♻️ Use Bun.SQL instead of pg
Some checks failed
CodeQL Scan / Analyze (javascript-typescript) (push) Failing after 1s
Build Docker Images / lint (push) Failing after 7s
Build Docker Images / check (push) Failing after 7s
Build Docker Images / tests (push) Failing after 7s
Deploy Docs to GitHub Pages / build (push) Failing after 0s
Build Docker Images / build (server, Dockerfile, ${{ github.repository_owner }}/server) (push) Has been skipped
Build Docker Images / build (worker, Worker.Dockerfile, ${{ github.repository_owner }}/worker) (push) Has been skipped
Deploy Docs to GitHub Pages / Deploy (push) Has been skipped
Mirror to Codeberg / Mirror (push) Failing after 0s
Nix Build / check (push) Failing after 0s
Some checks failed
CodeQL Scan / Analyze (javascript-typescript) (push) Failing after 1s
Build Docker Images / lint (push) Failing after 7s
Build Docker Images / check (push) Failing after 7s
Build Docker Images / tests (push) Failing after 7s
Deploy Docs to GitHub Pages / build (push) Failing after 0s
Build Docker Images / build (server, Dockerfile, ${{ github.repository_owner }}/server) (push) Has been skipped
Build Docker Images / build (worker, Worker.Dockerfile, ${{ github.repository_owner }}/worker) (push) Has been skipped
Deploy Docs to GitHub Pages / Deploy (push) Has been skipped
Mirror to Codeberg / Mirror (push) Failing after 0s
Nix Build / check (push) Failing after 0s
This commit is contained in:
parent
f95f57c4d4
commit
138f4fade3
6 changed files with 21 additions and 19 deletions
|
|
@ -1,13 +1,13 @@
|
|||
import { getLogger } from "@logtape/logtape";
|
||||
import { SQL } from "bun";
|
||||
import chalk from "chalk";
|
||||
import { drizzle, type NodePgDatabase } from "drizzle-orm/node-postgres";
|
||||
import { type BunSQLDatabase, drizzle } from "drizzle-orm/bun-sql";
|
||||
import { withReplicas } from "drizzle-orm/pg-core";
|
||||
import { migrate } from "drizzle-orm/postgres-js/migrator";
|
||||
import { Pool } from "pg";
|
||||
import { config } from "~/config.ts";
|
||||
import * as schema from "./schema.ts";
|
||||
|
||||
const primaryDb = new Pool({
|
||||
const primaryDb = new SQL({
|
||||
host: config.postgres.host,
|
||||
port: config.postgres.port,
|
||||
user: config.postgres.username,
|
||||
|
|
@ -17,7 +17,7 @@ const primaryDb = new Pool({
|
|||
|
||||
const replicas = config.postgres.replicas.map(
|
||||
(replica) =>
|
||||
new Pool({
|
||||
new SQL({
|
||||
host: replica.host,
|
||||
port: replica.port,
|
||||
user: replica.username,
|
||||
|
|
@ -32,9 +32,9 @@ export const db =
|
|||
drizzle(primaryDb, { schema }),
|
||||
replicas.map((r) => drizzle(r, { schema })) as [
|
||||
// biome-ignore lint/style/useNamingConvention: <explanation>
|
||||
NodePgDatabase<typeof schema> & { $client: Pool },
|
||||
BunSQLDatabase<typeof schema> & { $client: SQL },
|
||||
// biome-ignore lint/style/useNamingConvention: <explanation>
|
||||
...(NodePgDatabase<typeof schema> & { $client: Pool })[],
|
||||
...(BunSQLDatabase<typeof schema> & { $client: SQL })[],
|
||||
],
|
||||
)
|
||||
: drizzle(primaryDb, { schema });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue