Skip to content

MG08 — TRUNCATE ... CASCADE empties dependent tables too

Group: Migration safety · Auto-fixable: no

CASCADE truncates not only the named tables but every table with a foreign key into them, which can wipe far more data than intended. Truncate the dependent tables explicitly instead.

bad: TRUNCATE t CASCADE;
good: TRUNCATE t, dependent_table;

Disable this rule in banshee.toml:

[lint]
exclude = ["MG08"]

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