Why does my SurrealDB migration fail with Missing COMMIT statement?
BEGIN without COMMIT
Critical: SurrealDB refuses the migration, loses data, or leaks a credential.
What happens
Observed on SurrealDB 3.0.2: BEGIN; CREATE a:1; fails the whole query with "Missing COMMIT statement", and the table a does not exist afterwards.
Why it is dangerous on a populated table
Table size does not change this one: SurrealDB rejects the whole query before it applies anything, on an empty database and a full one alike.
Fires on
BEGIN TRANSACTION;
UPDATE user SET plan = 'free' WHERE plan IS NONE;The safe pattern
Close every BEGIN with COMMIT, or CANCEL, in the same file.
BEGIN TRANSACTION;
UPDATE user SET plan = 'free' WHERE plan IS NONE;
COMMIT TRANSACTION;Fixtures
The rule ships with these files and the test suite runs them on every change: the first set must fire, the second must stay silent.
Fires (2)
BEGIN TRANSACTION;
UPDATE user SET plan = 'free' WHERE plan IS NONE;BEGIN;
DEFINE FIELD nickname ON TABLE user TYPE option<string>;
COMMIT;
BEGIN;
DEFINE FIELD bio ON TABLE user TYPE option<string>;Stays silent (2)
BEGIN;
UPDATE user SET plan = 'free' WHERE plan IS NONE;
CANCEL;BEGIN TRANSACTION;
UPDATE user SET plan = 'free' WHERE plan IS NONE;
COMMIT TRANSACTION;How to check locally
SurrealDB support is in beta: this rule runs locally in the free CLI over .surql migrations, static only, and not in the hosted service yet. No install, nothing leaves your machine:
npx bolvrk check migration.surql --engine=surrealdb