-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Use mysql database driver #1186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,10 @@ | ||
| import { instrumentDrizzleClient } from "@kubiks/otel-drizzle"; | ||
| import { Client, type Config } from "@planetscale/database"; | ||
| import { sql } from "drizzle-orm"; | ||
| import type { AnyMySqlColumn } from "drizzle-orm/mysql-core"; | ||
| import { drizzle } from "drizzle-orm/planetscale-serverless"; | ||
| import { drizzle } from "drizzle-orm/mysql2"; | ||
|
|
||
| function createDrizzle() { | ||
| const URL = process.env.DATABASE_URL!; | ||
|
|
||
| let fetchHandler: Promise<Config["fetch"]> | undefined; | ||
|
|
||
| if (URL.startsWith("mysql://")) { | ||
| fetchHandler = import("@mattrax/mysql-planetscale").then((m) => | ||
| m.createFetchHandler(URL), | ||
| ); | ||
| } | ||
|
|
||
| const connection = new Client({ | ||
| url: URL, | ||
| fetch: async (input, init) => { | ||
| return await ((await fetchHandler) || fetch)(input, init); | ||
| }, | ||
| }); | ||
|
|
||
| return drizzle(connection); | ||
| return drizzle(process.env.DATABASE_URL_MYSQL!); | ||
| } | ||
|
Comment on lines
6
to
8
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix: DATABASE_URL_MYSQL must be validated as non-undefined. Line 8 passes Apply this diff to ensure the environment variable exists: function createDrizzle() {
- return drizzle(process.env.DATABASE_URL_MYSQL);
+ const url = process.env.DATABASE_URL_MYSQL;
+ if (!url) {
+ throw new Error("DATABASE_URL_MYSQL environment variable is not set");
+ }
+ return drizzle(url);
}Alternatively, if you're using a validated environment helper (like import { serverEnv } from "@cap/env";
function createDrizzle() {
return drizzle(serverEnv().DATABASE_URL_MYSQL);
}🧰 Tools🪛 GitHub Check: Typecheck[failure] 8-8: [failure] 8-8: 🤖 Prompt for AI Agents |
||
|
|
||
| let _cached: ReturnType<typeof createDrizzle> | undefined; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verify environment variable name expected by the application.
The Vercel environment variable is being set with key
DATABASE_URL_MYSQL, but application code typically expectsDATABASE_URL. On line 291, the workflow cluster is configured withDATABASE_URL: secrets.DATABASE_URL_MYSQL.value, suggesting the application expectsDATABASE_URLas the key.Apply this diff if the application expects
DATABASE_URL:Alternatively, if the application has been updated to use
DATABASE_URL_MYSQL, verify with:🤖 Prompt for AI Agents