Skip to content

Remove BEGIN/COMMIT from migration 0021 (D1 rejects) - #487

Merged
neuromechanist merged 1 commit into
devfrom
feature/migration-0021-d1-fix
May 14, 2026
Merged

neuromechanist merged 1 commit into
devfrom
feature/migration-0021-d1-fix

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Release blocker discovered while landing #474 (dev → main).

The `deploy-dev` job on dev's tip failed when applying migration `0021_broadcast_user_recipient.sql`:

```
ERROR: To execute a transaction, please use the state.storage.transaction() or
state.storage.transactionSync() APIs instead of the SQL BEGIN TRANSACTION or
SAVEPOINT statements. [code: 7500]
```

Cloudflare D1 explicitly forbids `BEGIN TRANSACTION` / `COMMIT` statements; the runtime already wraps each migration in an atomic transaction. The round-2 fix on PR #461 that wrapped the rebuild in `BEGIN;/COMMIT;` was the right intent for plain SQLite but wrong for D1.

Fix

Remove the `BEGIN;` and `COMMIT;` lines. Update the header comment to document the D1 constraint so future migration authors don't repeat the mistake.

Risk

D1 still atomically applies each migration via its built-in transaction wrap. The rebuild semantics (CREATE new + INSERT-SELECT + DROP old + RENAME) are unchanged.

Test

  • `bun test backend/test/migrations.test.ts` — 14/14 pass (the in-memory SQLite test in Add migration 0021 integration test #485 used bun:sqlite which tolerates the BEGIN/COMMIT; same test still passes without them).
  • Apply this migration on dev D1 to confirm `deploy-dev` job passes.

Why this matters

Without this fix, v0.8.14 cannot deploy. Migration 0021 is required by the new `admin notify --user` flag in #381.

@github-actions

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR487

Version: 0.8.14-PR487.f9e65ec
Commit: f9e65ec


🤖 Updated on each push.

@neuromechanist
neuromechanist merged commit eea0cfe into dev May 14, 2026
7 of 9 checks passed
@neuromechanist
neuromechanist deleted the feature/migration-0021-d1-fix branch May 14, 2026 12:45

This branch was previously deployed

1 inactive deployment
npm — f9e65ec5 Deployed May 14, 2026 by neuromechanist via publish #869
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant