Repository navigation
fix(core): detect Postgres after adapter minification - #2193
Conversation
🦋 Changeset detectedLatest commit: 10944e7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 17 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
This is the right fix for the right problem. Using instanceof PostgresAdapter instead of adapter.constructor.name correctly survives production bundlers that rename classes, and it avoids the false-positive classification of EmDash's coalescing D1/DO SQL adapters that a supportsMultipleConnections fallback (the alternative in #2138) would introduce.
I read the changed files, the AGENTS.md conventions, and searched packages/core for any other constructor.name based dialect checks. The fix is localized, the test directly reproduces the minified-name condition and would fail on the old string-matching implementation, and the changeset is user-facing. No conventions were violated: no UI/i18n changes, no new queries, no stale comments, and a changeset is present. LGTM.
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/auth-atproto
@emdash-cms/blocks
@emdash-cms/cloudflare
@emdash-cms/contentful-to-portable-text
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/plugin-cli
@emdash-cms/plugin-types
@emdash-cms/registry-client
@emdash-cms/registry-lexicons
@emdash-cms/registry-verification
@emdash-cms/sandbox-workerd
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-field-kit
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-demo-cache | 10944e7 | Jul 22 2026, 11:04 AM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-playground | 10944e7 | Jul 22 2026, 11:04 AM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-demo-do | 10944e7 | Jul 22 2026, 11:05 AM |
There was a problem hiding this comment.
Pull request overview
Fixes PostgreSQL dialect mis-detection during migrations when a consuming production build minifies/renames Kysely adapter class names. This change makes dialect detection resilient by switching from constructor.name matching to a class-identity (instanceof) check, keeping the rest of the dialect-specific SQL helpers consistent with the actual adapter in use.
Changes:
- Update
detectDialect()to detect Postgres viaadapter instanceof PostgresAdapterinstead ofadapter.constructor.name. - Add/adjust a unit test that simulates a bundler-renamed adapter constructor name and asserts Postgres is still detected.
- Add a patch changeset documenting the production migration fix.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/core/src/database/dialect-helpers.ts | Switch dialect detection to instanceof PostgresAdapter to survive minification. |
| packages/core/tests/unit/database/pg-migration-lock.test.ts | Regression test ensuring Postgres detection works even if adapter constructor name is mangled. |
| packages/core/src/database/pg-migration-lock.ts | Remove outdated comment tying correctness to preserving adapter class name. |
| .changeset/tidy-cats-detect.md | Patch changeset describing the Postgres migration fix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Visual regression: 5 screens changedThese admin screens render differently on this PR. Confirm every change below is intended before accepting.
Maintainers: if every change above is intended, comment Measured head: |





What does this PR do?
Fixes PostgreSQL migrations failing after a consuming production build renames Kysely adapter classes.
detectDialect()now usesPostgresAdapterclass identity, which survives minification, instead ofconstructor.name.This addresses the failure reported by the Cloudflare Blog team on upgrade to 0.30.0:
This is an alternative to #2138. It avoids that PR's
supportsMultipleConnectionsfallback, which would misclassify EmDash's coalescing D1 and DO SQL adapters as PostgreSQL.Closes #
Type of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (targeted tests for this change)pnpm formathas been runAI-generated code disclosure
Screenshots / test output
pnpm buildpnpm typecheckpnpm lint:json | jq '.diagnostics | length'(0)EMDASH_TEST_PG=postgres://postgres:test@localhost:5432/emdash_test pnpm --filter emdash test --run tests/unit/database/pg-migration-lock.test.ts tests/integration/database/dialect-compat.test.ts(31 passed across SQLite and PostgreSQL)The PostgreSQL run applies every migration through
051_content_taxonomies_denormagainst the local PostgreSQL server.