Skip to content

Commit

Permalink
Fix 'db studio' command
Browse files Browse the repository at this point in the history
Change from using postgres to node-postgres because the drizzle-kit
studio does not support postgres-js.

To prevent having several postgres clients, we also switch our migration
script to use node-postgres
  • Loading branch information
venables committed Sep 17, 2023
1 parent 4cdd24c commit d967d10
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions bin/migrate.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { drizzle } from "drizzle-orm/postgres-js"
import { migrate } from "drizzle-orm/postgres-js/migrator"
import { drizzle } from "drizzle-orm/node-postgres"
import { migrate } from "drizzle-orm/node-postgres/migrator"
import { join } from "path"
import postgres from "postgres"
import { Client } from "pg"

import { env } from "@/env"

const client = postgres(env.DATABASE_URL, { ssl: "require", max: 1 })
const client = new Client({
connectionString: `${env.DATABASE_URL}?sslmode=require`
})
const db = drizzle(client)

console.log("Migrating the database ...")
Expand Down
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Config } from "drizzle-kit"

const connectionString = process.env.DATABASE_URL
const connectionString = `${process.env.DATABASE_URL}?sslmode=require`

if (!connectionString) {
throw new Error("DATABASE_URL is not set")
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@
"next-secure-headers": "^2.2.0",
"npm-run-all": "^4.1.5",
"patch-package": "^8.0.0",
"pg": "^8.11.3",
"postcss": "^8.4.29",
"postgres": "^3.3.5",
"prettier": "^3.0.3",
"react-email": "^1.9.4",
"tailwindcss": "^3.3.3",
Expand Down

1 comment on commit d967d10

@vercel
Copy link

@vercel vercel bot commented on d967d10 Sep 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.