banDropTrigger¶
Group safety · Migrations only · Since 0.25.0
Diagnostic lint/banDropTrigger
Sources: inspired by pgfence/drop-trigger
Description¶
Dropping a trigger acquires an ACCESS EXCLUSIVE lock on the table.
DROP TRIGGER blocks all reads and writes on the table while the lock is held.
It may also break application logic that depends on the trigger's behavior.
Examples¶
Invalid¶
drop trigger my_trigger on my_table;
code-block.sql:1:1 lint/banDropTrigger ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Dropping a trigger acquires an ACCESS EXCLUSIVE lock on the table.
> 1 │ drop trigger my_trigger on my_table;
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │
i This blocks all reads and writes. Ensure no application logic depends on the trigger before dropping it.
Valid¶
select 1;
How to configure¶
{
"linter": {
"rules": {
"banDropTrigger": "error"
}
}
}
How to suppress¶
Suppress this diagnostic with a comment:
-- pgls-ignore banDropTrigger