Skip to content

fix: migration 033 idempotency & smoke test cleanup - #365

Merged
ascorbic merged 4 commits into
mainfrom
fix/smoke-test-cleanup
Apr 7, 2026
Merged

ascorbic merged 4 commits into
mainfrom
fix/smoke-test-cleanup

Conversation

@ascorbic

@ascorbic ascorbic commented Apr 7, 2026

Copy link
Copy Markdown
Member

What does this PR do?

Two fixes:

  1. Migration 033 fails on databases where indexes already exist. The schema registry's createContentTable() creates composite indexes at table creation time. When migration 033 runs on a database with tables created after the registry was updated, it fails with index already exists. Fixed by adding IF NOT EXISTS to all CREATE INDEX statements.

  2. Smoke tests were slow and redundant. The site matrix included every demo, template, and typecheck case — running sequential astro build for 12+ sites. Trimmed to templates + playground (the release artifacts), replaced sequential builds with a single recursive pnpm build, and removed typecheck cases (already covered by pnpm typecheck).

Closes #150

Type of change

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

Checklist

AI-generated code disclosure

  • This PR includes AI-generated code

Screenshots / test output

 ✓ tests/integration/smoke/site-matrix-smoke.test.ts (9 tests) 94343ms
 ✓ tests/integration/smoke/template-smoke.test.ts (147 tests)

 Test Files  2 passed (2)
      Tests  156 passed (156)
   Duration  94.47s

ascorbic added 4 commits April 7, 2026 22:50
The schema registry's createContentTable() creates composite indexes
on content tables at creation time. When migration 033 runs on a
database where tables were created after the registry added these
indexes, it fails with "index already exists". Adding IF NOT EXISTS
makes the migration idempotent.
…ypechecks

The smoke test matrix included every demo and template, plus typecheck
cases. This was slow and redundant — typechecks are already covered by
pnpm typecheck, and demos are dev targets not release artifacts.

Trim to templates + playground only, and replace the sequential per-site
astro build with a single recursive pnpm build. Remove the TypecheckSiteCase
type and handling since smoke tests should only verify runtime behavior.
Copilot AI review requested due to automatic review settings April 7, 2026 21:54
@changeset-bot

changeset-bot Bot commented Apr 7, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: da14bac

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

This PR includes changesets to release 9 packages
Name Type
emdash Patch
@emdash-cms/cloudflare Patch
@emdash-cms/plugin-ai-moderation Patch
@emdash-cms/plugin-atproto Patch
@emdash-cms/plugin-audit-log Patch
@emdash-cms/plugin-color Patch
@emdash-cms/plugin-embeds Patch
@emdash-cms/plugin-forms Patch
@emdash-cms/plugin-webhook-notifier 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

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Apr 7, 2026 •

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 da14bac Apr 07 2026, 09:56 PM

@pkg-pr-new

pkg-pr-new Bot commented Apr 7, 2026

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

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

@emdash-cms/auth

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

@emdash-cms/blocks

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

@emdash-cms/cloudflare

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

emdash

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

create-emdash

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

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

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

@emdash-cms/x402

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

@emdash-cms/plugin-ai-moderation

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

@emdash-cms/plugin-atproto

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

@emdash-cms/plugin-audit-log

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

@emdash-cms/plugin-color

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

@emdash-cms/plugin-embeds

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

@emdash-cms/plugin-forms

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

@emdash-cms/plugin-webhook-notifier

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

commit: da14bac

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

This PR improves database migration robustness and reduces integration smoke-test runtime by making migration 033 idempotent and simplifying the site matrix/build strategy.

Changes:

  • Make migration 033_optimize_content_indexes idempotent by adding IF NOT EXISTS to index creation.
  • Reduce smoke-test scope and speed up builds by switching to a single recursive pnpm build and removing typecheck-only cases from the site matrix.
  • Remove posts collection typings from select templates’ emdash-env.d.ts files.

Reviewed changes

Copilot reviewed 3 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/core/src/database/migrations/033_optimize_content_indexes.ts Adds CREATE INDEX IF NOT EXISTS to prevent failures when indexes already exist.
packages/core/tests/integration/smoke/site-matrix-smoke.test.ts Shrinks the runtime site matrix and replaces per-site builds with a single recursive workspace build.
templates/portfolio/emdash-env.d.ts Removes posts collection typings from the portfolio template.
templates/portfolio-cloudflare/emdash-env.d.ts Removes posts collection typings from the portfolio-cloudflare template.
templates/marketing/emdash-env.d.ts Removes posts collection typings from the marketing template.
.changeset/cute-news-follow.md Adds a patch changeset describing the migration fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

port: 4617,
mode: "runtime",
startupTimeoutMs: 120_000,
},

Copilot AI Apr 7, 2026

Copy link

Choose a reason for hiding this comment

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

SITE_MATRIX no longer includes the templates/starter and templates/starter-cloudflare sites, even though those template directories exist in the repo. If the intent is to keep runtime smoke tests covering all shipped templates, consider adding these two templates back into the runtime matrix (or clarify in the test/PR description why they’re intentionally excluded).

Suggested change
},
},
{
name: "templates/starter",
dir: resolve(WORKSPACE_ROOT, "templates/starter"),
port: 4618,
startupTimeoutMs: 60_000,
},
{
name: "templates/starter-cloudflare",
dir: resolve(WORKSPACE_ROOT, "templates/starter-cloudflare"),
port: 4619,
startupTimeoutMs: 120_000,
},

Copilot uses AI. Check for mistakes.
@ascorbic
ascorbic merged commit d6cfc43 into main Apr 7, 2026
31 checks passed
@ascorbic
ascorbic deleted the fix/smoke-test-cleanup branch April 7, 2026 22:00
This was referenced Apr 7, 2026
fmhall pushed a commit to fmhall/emdash that referenced this pull request Apr 13, 2026
* fix(core): add IF NOT EXISTS to migration 033 index creation

The schema registry's createContentTable() creates composite indexes
on content tables at creation time. When migration 033 runs on a
database where tables were created after the registry added these
indexes, it fails with "index already exists". Adding IF NOT EXISTS
makes the migration idempotent.

* refactor(smoke): trim site matrix to templates + playground, remove typechecks

The smoke test matrix included every demo and template, plus typecheck
cases. This was slow and redundant — typechecks are already covered by
pnpm typecheck, and demos are dev targets not release artifacts.

Trim to templates + playground only, and replace the sequential per-site
astro build with a single recursive pnpm build. Remove the TypecheckSiteCase
type and handling since smoke tests should only verify runtime behavior.

* Update env

* chore: add changeset for migration 033 fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

webhook-notifier 400 error

2 participants