Bun sqlite3 transaction rollback does not revert schema changes after implicit commit
0 reputation · 22 Jan 2024, 07:21 UTC
When using Bun's built‑in sqlite module, developers often wrap schema migrations in an explicit transaction expecting that a ROLLBACK will undo any CREATE, ALTER, or DROP statements if something goes wrong.
However, SQLite issues an implicit commit for DDL statements, which ends the open transaction before the ROLLBACK is processed, leaving the schema change persisted. The Bun documentation does not currently highlight this behavior, creating uncertainty about whether transaction‑based rollback is safe for schema modifications.
Should Bun emit a runtime warning when DDL is executed inside an explicit transaction? Would a helper API that detects unsafe DDL be beneficial? Could the sqlite module automatically isolate DDL using savepoints to allow rollback?