Skip to content

Support deployment-managed migrations instead of runtime auto-migrations #2276

Closed

Description

@mvvmm

EmDash currently runs pending core migrations during runtime initialization. On Cloudflare Workers/Hyperdrive, that can happen inside the first visitor request or cron event for a cold isolate.

That behavior is risky for deployed environments:

  • Deploys can succeed even if migrations later fail.
  • Visitor requests or cron events can pay migration latency.
  • Multiple isolates can contend on migration locks.
  • Schema mutations happen during request handling.
  • Failures surface as live request failures instead of failed CI/deployments.
  • Shared preview/staging databases can be mutated unexpectedly by runtime traffic.

For production-like environments, migrations should be deployment-managed:

  • Production: never apply migrations during request/cron lifecycle.
  • Staging: same as production, so it catches deploy/migration failures early.
  • Shared previews: same as production, especially when previews share DB state.
  • Local dev: auto-migration is useful, ideally before emdash dev starts rather than mid-request.

Could EmDash provide a supported CI/operator migration path and a runtime mode that does not apply migrations?

Possible shape:

  • emdash migrate to apply pending migrations explicitly.
  • emdash migrate --check to fail non-zero if migrations are pending.
  • Support Postgres direct URLs, D1, and SQLite.
  • Print applied/pending migrations.
  • Document GitHub/GitLab/Wrangler deploy ordering.

Possible runtime config:

emdash({
  migrations: {
    mode: "auto" | "check" | "manual"
  }
})

Suggested semantics:

  • auto: current behavior; applies pending migrations at runtime.
  • check: runtime verifies migrations are current and fails loudly if pending, without mutating schema.
  • manual: runtime does not check or apply migrations; CI/operator is responsible.

The default could remain auto for backward compatibility, but production/staging/shared-preview docs and templates should recommend check or manual with an explicit CI migration step.

Activity

  1. ascorbic commented on Aug 11, 2026

    @ascorbic
    Member

    Proposal here: #2418

  2. added this to the 1.0 milestone on Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions