Skip to content

fix(core): detect Postgres after adapter minification - #2193

Merged
ascorbic merged 1 commit into
mainfrom
fix/postgres-dialect-minification
Jul 22, 2026
Merged

ascorbic merged 1 commit into
mainfrom
fix/postgres-dialect-minification

Conversation

@ascorbic

@ascorbic ascorbic commented Jul 22, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

Fixes PostgreSQL migrations failing after a consuming production build renames Kysely adapter classes. detectDialect() now uses PostgresAdapter class identity, which survives minification, instead of constructor.name.

This addresses the failure reported by the Cloudflare Blog team on upgrade to 0.30.0:

Migration failed: function pragma_table_info(unknown) does not exist (migration: 051_content_taxonomies_denorm)

This is an alternative to #2138. It avoids that PR's supportsMultipleConnections fallback, which would misclassify EmDash's coalescing D1 and DO SQL adapters as PostgreSQL.

Closes #

Type of change

  • Bug fix
  • Feature (requires maintainer-approved Discussion)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test passes (targeted tests for this change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • User-visible strings in the admin UI are wrapped for translation (not applicable, no UI changes)
  • I have added a changeset
  • New features link to an approved Discussion (not applicable, bug fix)

AI-generated code disclosure

  • This PR includes AI-generated code - model/tool: GPT-5.6 Sol

Screenshots / test output

  • pnpm build
  • pnpm typecheck
  • pnpm 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_denorm against the local PostgreSQL server.

Copilot AI review requested due to automatic review settings July 22, 2026 11:01
@github-actions github-actions Bot added review/needs-review No maintainer or bot review yet area/core size/S labels Jul 22, 2026
@changeset-bot

changeset-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 10944e7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 17 packages
Name Type
emdash Patch
@emdash-cms/cloudflare Patch
@emdash-cms/sandbox-workerd Patch
@emdash-cms/plugin-mcp-smoke Patch
@emdash-cms/fixture-perf-site Patch
@emdash-cms/perf-demo-site Patch
@emdash-cms/cache-demo-site Patch
@emdash-cms/do-demo-site Patch
@emdash-cms/do-solo-demo-site Patch
@emdash-cms/admin Patch
@emdash-cms/auth Patch
@emdash-cms/blocks Patch
@emdash-cms/gutenberg-to-portable-text Patch
@emdash-cms/x402 Patch
create-emdash Patch
@emdash-cms/auth-atproto Patch
@emdash-cms/plugin-embeds Patch

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

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@pkg-pr-new

pkg-pr-new Bot commented Jul 22, 2026

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@2193

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@2193

@emdash-cms/auth-atproto

npm i https://pkg.pr.new/@emdash-cms/auth-atproto@2193

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@2193

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@2193

@emdash-cms/contentful-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/contentful-to-portable-text@2193

emdash

npm i https://pkg.pr.new/emdash@2193

create-emdash

npm i https://pkg.pr.new/create-emdash@2193

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@2193

@emdash-cms/plugin-cli

npm i https://pkg.pr.new/@emdash-cms/plugin-cli@2193

@emdash-cms/plugin-types

npm i https://pkg.pr.new/@emdash-cms/plugin-types@2193

@emdash-cms/registry-client

npm i https://pkg.pr.new/@emdash-cms/registry-client@2193

@emdash-cms/registry-lexicons

npm i https://pkg.pr.new/@emdash-cms/registry-lexicons@2193

@emdash-cms/registry-verification

npm i https://pkg.pr.new/@emdash-cms/registry-verification@2193

@emdash-cms/sandbox-workerd

npm i https://pkg.pr.new/@emdash-cms/sandbox-workerd@2193

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@2193

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@2193

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@2193

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@2193

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@2193

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@2193

@emdash-cms/plugin-field-kit

npm i https://pkg.pr.new/@emdash-cms/plugin-field-kit@2193

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@2193

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@2193

commit: 10944e7

@github-actions github-actions Bot added review/approved Approved; no new commits since and removed review/needs-review No maintainer or bot review yet labels Jul 22, 2026
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-demo-cache 10944e7 Jul 22 2026, 11:04 AM

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-playground 10944e7 Jul 22 2026, 11:04 AM

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-demo-do 10944e7 Jul 22 2026, 11:05 AM

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 via adapter instanceof PostgresAdapter instead of adapter.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.

@github-actions

Copy link
Copy Markdown
Contributor

Visual regression: 5 screens changed

These admin screens render differently on this PR. Confirm every change below is intended before accepting.

Screen Image Compare
content-editor-ltr expected · actual
content-editor-rtl expected · actual
content-new-ltr expected · actual
content-new-rtl expected · actual
dashboard-rtl expected · actual

Maintainers: if every change above is intended, comment /accept-baselines
to commit the regenerated Linux baselines to this PR.

Measured head: 10944e75de618e073774159af8c5036610275e2d. /accept-baselines accepts the snapshots for this commit.

github-actions Bot pushed a commit that referenced this pull request Jul 22, 2026
@ascorbic
ascorbic merged commit 791c0eb into main Jul 22, 2026
52 of 53 checks passed
@ascorbic
ascorbic deleted the fix/postgres-dialect-minification branch July 22, 2026 11:22
@emdashbot emdashbot Bot mentioned this pull request Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core review/approved Approved; no new commits since size/S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants