-
-
Notifications
You must be signed in to change notification settings - Fork 431
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use planetscale -> supabase (#1024)
* move to supabase * readme * auth bump * fix typecheck
- Loading branch information
1 parent
0a6f0d2
commit f7f7bd9
Showing
14 changed files
with
388 additions
and
321 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,14 @@ | ||
import type { Config } from "drizzle-kit"; | ||
import { createEnv } from "@t3-oss/env-core"; | ||
import * as z from "zod"; | ||
|
||
const env = createEnv({ | ||
server: { | ||
DB_HOST: z.string(), | ||
DB_NAME: z.string(), | ||
DB_USERNAME: z.string(), | ||
DB_PASSWORD: z.string(), | ||
}, | ||
runtimeEnv: process.env, | ||
emptyStringAsUndefined: true, | ||
}); | ||
if (!process.env.POSTGRES_URL) { | ||
throw new Error("Missing POSTGRES_URL"); | ||
} | ||
|
||
// Push requires SSL so use URL instead of username/password | ||
export const connectionStr = new URL(`mysql://${env.DB_HOST}/${env.DB_NAME}`); | ||
connectionStr.username = env.DB_USERNAME; | ||
connectionStr.password = env.DB_PASSWORD; | ||
connectionStr.searchParams.set("ssl", '{"rejectUnauthorized":true}'); | ||
const nonPoolingUrl = process.env.POSTGRES_URL.replace(":6543", ":5432"); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
export default { | ||
schema: "./src/schema", | ||
driver: "mysql2", | ||
dbCredentials: { uri: connectionStr.href }, | ||
dialect: "postgresql", | ||
dbCredentials: { url: nonPoolingUrl }, | ||
tablesFilter: ["t3turbo_*"], | ||
} satisfies Config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import { mysqlTableCreator } from "drizzle-orm/mysql-core"; | ||
import { pgTableCreator } from "drizzle-orm/pg-core"; | ||
|
||
/** | ||
* This is an example of how to use the multi-project schema feature of Drizzle ORM. | ||
* Use the same database instance for multiple projects. | ||
* | ||
* @see https://orm.drizzle.team/docs/goodies#multi-project-schema | ||
*/ | ||
export const mySqlTable = mysqlTableCreator((name) => `t3turbo_${name}`); | ||
export const pgTable = pgTableCreator((name) => `t3turbo_${name}`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
import { sql } from "drizzle-orm"; | ||
import { serial, timestamp, varchar } from "drizzle-orm/mysql-core"; | ||
import { text, timestamp, uuid, varchar } from "drizzle-orm/pg-core"; | ||
|
||
import { mySqlTable } from "./_table"; | ||
import { pgTable } from "./_table"; | ||
|
||
export const post = mySqlTable("post", { | ||
id: serial("id").primaryKey(), | ||
export const post = pgTable("post", { | ||
id: uuid("id").notNull().primaryKey().defaultRandom(), | ||
title: varchar("name", { length: 256 }).notNull(), | ||
content: varchar("content", { length: 256 }).notNull(), | ||
content: text("content").notNull(), | ||
createdAt: timestamp("created_at") | ||
.default(sql`CURRENT_TIMESTAMP`) | ||
.default(sql`now()`) | ||
.notNull(), | ||
updatedAt: timestamp("updatedAt").onUpdateNow(), | ||
updatedAt: timestamp("updatedAt", { | ||
mode: "date", | ||
withTimezone: true, | ||
}).$onUpdateFn(() => sql`now()`), | ||
}); |
Oops, something went wrong.
Curious to know the reason behind this. I see that Supabase recommends 6543 with @vercel/postgres, https://supabase.com/docs/guides/database/connecting-to-postgres/serverless-drivers#manual-configuration, but the @vercel/postgres client with Neon is 5432, https://orm.drizzle.team/learn/tutorials/drizzle-with-vercel-edge-functions#vercel-postgres-client.