banDropType¶
Group destructive · Migrations only · Since Unreleased
Diagnostic lint/banDropType · Postgres error 42704
Sources: inspired by squawk/ban-drop-type
Description¶
Dropping a type, cast, operator, operator class, or operator family may break existing clients.
Casts and parameters that name a dropped type fail with 42704 undefined_object. With
CASCADE, columns of that type are dropped too.
Update your application code to no longer use the type, then drop it in a later migration.
Examples¶
Invalid¶
drop type order_status;
code-block.sql:1:1 lint/banDropType ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Dropping a type may break existing clients.
> 1 │ drop type order_status;
│ ^^^^^^^^^^^^^^^^^^^^^^^
2 │
i Queries that still use it fail, and rolling back the application does not restore it.
i Update your application code to no longer use it, then drop it in a later migration.
drop cast (text as point);
code-block.sql:1:1 lint/banDropType ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Dropping a cast may break existing clients.
> 1 │ drop cast (text as point);
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │
i Queries that still use it fail, and rolling back the application does not restore it.
i Update your application code to no longer use it, then drop it in a later migration.
How to configure¶
{
"linter": {
"rules": {
"banDropType": "error"
}
}
}
How to suppress¶
Suppress this diagnostic with a comment:
-- pgls-ignore banDropType