fix(den-db): support socketPath in DATABASE_URL for Cloud SQL connections#1841
Open
Dwij1704 wants to merge 1 commit into
Open
fix(den-db): support socketPath in DATABASE_URL for Cloud SQL connections#1841Dwij1704 wants to merge 1 commit into
Dwij1704 wants to merge 1 commit into
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
@Dwij1704 is attempting to deploy a commit to the Different AI Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
?socketPath(and the?socketalias) from the MySQLDATABASE_URLand pass it throughparseMySqlConnectionConfig.mysql2ignoreshost/portand connects via the Unix socket — fixing both the den-api runtime anddrizzle-kit db:push, sincedrizzle.config.tsalready routes through the same parser.mysql-config.test.tscovering TCP, socketPath, alias, precedence, empty value, SSL coexistence, and validation cases (10 tests).Why
On Google Cloud Run with Cloud SQL attached via a Unix socket, the recommended
DATABASE_URLismysql://user:pw@localhost/db?socketPath=/cloudsql/<conn>. The parser was dropping thesocketPathquery parameter entirely, somysql2fell back to TCP on127.0.0.1:3306, which is not available in Cloud Run, and every request 500'd withECONNREFUSED. The fix is single-source: becausedrizzle.config.tscalls the sameparseMySqlConnectionConfig, fixing the parser fixes migrations too.Issue
Scope
ee/packages/den-db/src/mysql-config.ts— type + parseree/packages/den-db/test/mysql-config.test.ts— new bun:test coverageOut of scope
client.tsordrizzle.config.ts— neither needs touching since they both spread the parser's return value.Testing
Ran
bun test ee/packages/den-db/test/mysql-config.test.ts— 10 pass / 0 failpnpm --filter @openwork-ee/den-db build— okpnpm test:e2e— exit 0 (no regression)Result
CI status
pnpm typecheckshows a pre-existing failure ondev(apps/app/src/react-app/domains/session/artifacts/artifact-spreadsheet-model.tscannot find modulexlsx) introduced by feat(app): open artifacts in session pane #1836. Unrelated to this change; den-db typechecks clean on its own (pnpm --filter @openwork-ee/den-db buildsucceeds).Manual verification
pnpm installbun test ee/packages/den-db/test/mysql-config.test.tspnpm --filter @openwork-ee/den-db buildDATABASE_URL=mysql://root:password@localhost/<db>?socketPath=/cloudsql/<project>:<region>:<instance>and runpnpm --filter @openwork-ee/den-db db:push; the migration should succeed instead of failing withECONNREFUSED 127.0.0.1:3306.Evidence
Risk
DATABASE_URLvalues are unchanged.Rollback