Add PostgreSQL support via pg and node-postgres drizzle adapter
This commit is contained in:
1 parent
79b0b8894d
commit
9cff32a04b
5 files changed
+2572
-4403
No files matched your search
@@ -8,6 +8,7 @@
|
|||||||
# directly (drizzle-kit, scripts). Keep both in step and keep them well below
|
# directly (drizzle-kit, scripts). Keep both in step and keep them well below
|
||||||
# MariaDB's `max_connections` (151 by default) or the emulator and any second
|
# MariaDB's `max_connections` (151 by default) or the emulator and any second
|
||||||
# CMS instance get "Too many connections". README §performance: pool size 25.
|
# CMS instance get "Too many connections". README §performance: pool size 25.
|
||||||
|
# DATABASE_URL supports both MySQL/MariaDB ("mysql://...") and PostgreSQL ("postgres://...").
|
||||||
DATABASE_URL="mysql://user:password@localhost:3306/dbname?charset=utf8mb4&connection_limit=25&connect_timeout=5"
|
DATABASE_URL="mysql://user:password@localhost:3306/dbname?charset=utf8mb4&connection_limit=25&connect_timeout=5"
|
||||||
DATABASE_POOL_SIZE=25
|
DATABASE_POOL_SIZE=25
|
||||||
DATABASE_IDLE_TIMEOUT_MS=60000
|
DATABASE_IDLE_TIMEOUT_MS=60000
|
||||||
|
|||||||
+5
-2
@@ -6,12 +6,15 @@ import { defineConfig } from "drizzle-kit";
|
|||||||
// This DB is shared with the Arcturus emulator — NEVER run `drizzle-kit migrate`
|
// This DB is shared with the Arcturus emulator — NEVER run `drizzle-kit migrate`
|
||||||
// or `push` against it. CMS DDL stays in drizzle/migrations/*.sql applied by
|
// or `push` against it. CMS DDL stays in drizzle/migrations/*.sql applied by
|
||||||
// `pnpm db:migrate`. Use `pnpm db:generate` only for draft SQL under drizzle/drafts/.
|
// `pnpm db:migrate`. Use `pnpm db:generate` only for draft SQL under drizzle/drafts/.
|
||||||
|
const dbUrl = process.env.DATABASE_URL ?? "";
|
||||||
|
const isPostgres = dbUrl.startsWith("postgres://") || dbUrl.startsWith("postgresql://");
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
dialect: "mysql",
|
dialect: isPostgres ? "postgresql" : "mysql",
|
||||||
schema: "./src/db/schema.ts",
|
schema: "./src/db/schema.ts",
|
||||||
out: "./drizzle/drafts",
|
out: "./drizzle/drafts",
|
||||||
dbCredentials: {
|
dbCredentials: {
|
||||||
url: process.env.DATABASE_URL ?? "",
|
url: dbUrl,
|
||||||
},
|
},
|
||||||
strict: true,
|
strict: true,
|
||||||
verbose: true,
|
verbose: true,
|
||||||
|
|||||||
@@ -79,6 +79,7 @@
|
|||||||
"next-auth": "5.0.0-beta.32",
|
"next-auth": "5.0.0-beta.32",
|
||||||
"next-intl": "4.14.9",
|
"next-intl": "4.14.9",
|
||||||
"otplib": "13.5.0",
|
"otplib": "13.5.0",
|
||||||
|
"pg": "^8.23.1",
|
||||||
"pino": "10.4.0",
|
"pino": "10.4.0",
|
||||||
"react": "19.3.1",
|
"react": "19.3.1",
|
||||||
"react-dom": "19.3.1",
|
"react-dom": "19.3.1",
|
||||||
@@ -100,6 +101,7 @@
|
|||||||
"@tailwindcss/postcss": "4.3.3",
|
"@tailwindcss/postcss": "4.3.3",
|
||||||
"@tailwindcss/typography": "0.5.20",
|
"@tailwindcss/typography": "0.5.20",
|
||||||
"@types/node": "26.6.5",
|
"@types/node": "26.6.5",
|
||||||
|
"@types/pg": "^8.23.1",
|
||||||
"@types/react": "19.3.0",
|
"@types/react": "19.3.0",
|
||||||
"@types/react-dom": "19.3.0",
|
"@types/react-dom": "19.3.0",
|
||||||
"@vitest/coverage-v8": "5.0.5",
|
"@vitest/coverage-v8": "5.0.5",
|
||||||
|
|||||||
Generated
+2502
-4394
File diff suppressed because it is too large.
Load diff
+62
-7
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user