Skip to content

refactor: export MIGRATION_COUNT from runner to replace hardcoded test assertions#347

Merged
ascorbic merged 3 commits intomainfrom
refactor/migration-count-from-runner
Apr 7, 2026
Merged

refactor: export MIGRATION_COUNT from runner to replace hardcoded test assertions#347
ascorbic merged 3 commits intomainfrom
refactor/migration-count-from-runner

Conversation

@MattieTK
Copy link
Copy Markdown
Collaborator

@MattieTK MattieTK commented Apr 7, 2026

What does this PR do?

Extracts the migrations map from inside StaticMigrationProvider.getMigrations() to a module-level const, and exports a MIGRATION_COUNT derived from Object.keys(). The three migration test files now import MIGRATION_COUNT instead of hardcoding the number.

Before, every new migration required updating 5 separate toHaveLength(N) calls across 3 files. Now it requires no test changes at all — the count is always derived from the source of truth.

Type of change

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

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes
  • pnpm --silent lint:json | jq '.diagnostics | length' returns 0
  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • I have added a changeset (if this PR changes a published package)
  • New features link to an approved Discussion: https://github.com/emdash-cms/emdash/discussions/...

AI-generated code disclosure

  • This PR includes AI-generated code

Copilot AI review requested due to automatic review settings April 7, 2026 10:17
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 7, 2026

⚠️ No Changeset found

Latest commit: ded9146

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Apr 7, 2026

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 ded9146 Apr 07 2026, 10:59 AM

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 7, 2026

Open in StackBlitz

@emdash-cms/admin

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

@emdash-cms/auth

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

@emdash-cms/blocks

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

@emdash-cms/cloudflare

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

emdash

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

create-emdash

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

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

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

@emdash-cms/x402

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

@emdash-cms/plugin-ai-moderation

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

@emdash-cms/plugin-atproto

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

@emdash-cms/plugin-audit-log

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

@emdash-cms/plugin-color

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

@emdash-cms/plugin-embeds

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

@emdash-cms/plugin-forms

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

@emdash-cms/plugin-webhook-notifier

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

commit: ded9146

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors the core database migration runner to centralize the migration registry and exposes a derived migration count so tests no longer hardcode the expected number of migrations.

Changes:

  • Hoists the static migrations map in runner.ts to a module-level constant and exports MIGRATION_COUNT.
  • Updates migration-related tests to assert against MIGRATION_COUNT instead of hardcoded lengths.

Reviewed changes

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

File Description
packages/core/src/database/migrations/runner.ts Introduces module-level MIGRATIONS and exports MIGRATION_COUNT; StaticMigrationProvider now returns the shared map.
packages/core/tests/integration/database/migrations.test.ts Replaces hardcoded migration record counts with MIGRATION_COUNT.
packages/core/tests/integration/database/dialect-compat.test.ts Replaces hardcoded migration record counts with MIGRATION_COUNT across dialect tests.
packages/core/tests/database/migrations.test.ts Replaces hardcoded applied/record counts with MIGRATION_COUNT.

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Overlapping PRs

This PR modifies files that are also changed by other open PRs:

This may cause merge conflicts or duplicated work. A maintainer will coordinate.

@ascorbic ascorbic merged commit 3eb7e2c into main Apr 7, 2026
42 of 43 checks passed
@ascorbic ascorbic deleted the refactor/migration-count-from-runner branch April 7, 2026 22:26
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.

3 participants