MG06 — ALTER COLUMN TYPE rewrites the table under a lock
Group: Migration safety · Auto-fixable: no
Changing a column’s type rewrites the table under an exclusive lock and can fail or lose data on an incompatible conversion. Add a new column, backfill, and swap over instead. A provable safe widening (e.g. int -> bigint, varchar(50) -> text), determined from the column’s type history across the whole migration set, is not flagged.
Example
Section titled “Example”bad: ALTER TABLE t ALTER COLUMN c TYPE int; -- narrowing bigint -> intok: ALTER TABLE t ALTER COLUMN c TYPE bigint; -- widening int -> bigintConfigure
Section titled “Configure”Disable this rule in banshee.toml:
[lint]exclude = ["MG06"]Or silence one line with -- noqa: MG06. See Linting.