Skip to content

Migrations that Alchemy can apply to D1 and Durable Objects #59

Open

Description

@artile

Signal

We use Alchemy for all Cloudflare resources. We want effect-orm migrations in a format that Alchemy applies. For D1, that is D1Database({ migrationsDir }). For Durable Objects, it is a bundled list the object runs at start.

Why (MyRemotely / CAFE)

  • One source of truth: table definitions → generated SQL → Alchemy deploy. No second tool such as wrangler or drizzle-kit.
  • PR feat(sqlite): generate migrations #51 adds SQLite migration generation. This issue is about the delivery path.

Scope

  • Output layout that Alchemy D1 reads (ordered .sql files, journal).
  • A DO helper: Migrations.runOnStart(storage, bundledMigrations) with a ledger table inside the object.
  • Per-tenant fan-out: apply one migration to N tenant databases, with resume after a partial failure (the ClickHouse runner has a journal and resume already).

Done when

  • alchemy deploy creates a D1 database and applies effect-orm migrations to it.
  • A DO applies new migrations when it starts after a deploy.

Part of #52: the CAFE-stack roadmap signal from MyRemotely. This shows the direction we want, and it is not a demand. We can send a PR if you accept the idea.

Activity

  1. Makisuo commented on Oct 25, 2026

    @Makisuo
    Contributor

    The D1 half has started: #121 makes effect-orm generate write SQLite migrations in the drizzle-kit 1.0 layout (<timestamp>_<name>/migration.sql and snapshot.json), which Alchemy's D1 resource applies. The migration fuzzer checks each generated migration applied as one D1 batch. Still open: a Durable Object runner and ledger, per-tenant fan-out, and an alchemy deploy end-to-end test.

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

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions