Skip to content

MG22 — CREATE/DROP without IF [NOT] EXISTS is not idempotent

Group: Migration safety · Auto-fixable: no

A CREATE TABLE/INDEX or DROP without IF [NOT] EXISTS errors on re-run, so a migration that partially applied cannot be retried cleanly. Outside a transaction, prefer the idempotent form.

bad: CREATE TABLE t (a int);
good: CREATE TABLE IF NOT EXISTS t (a int);

Disable this rule in banshee.toml:

[lint]
exclude = ["MG22"]

Or silence one line with -- noqa: MG22. See Linting.