banDropSchema

Diagnostic Category: lint/safety/banDropSchema

Since: vnext

Note

This rule is recommended. A diagnostic error will appear when linting your code.

Sources: - Inspired from: pgfence/drop-schema

Description

Dropping a schema will remove all objects within it and may break existing clients.

A DROP SCHEMA statement removes the entire schema and all objects it contains. This is a destructive operation that can cause significant data loss and break dependent applications.

Examples

Invalid

drop schema my_schema;
code-block.sql:1:1 lint/safety/banDropSchema ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  × Dropping a schema will remove all objects within it and may break existing clients.

  > 1 │ drop schema my_schema;
      │ ^^^^^^^^^^^^^^^^^^^^^^
    2 │ 

  i Remove objects individually instead, or ensure all dependent applications have been updated.


Valid

select 1;

How to configure


{
  "linter": {
    "rules": {
      "safety": {
        "banDropSchema": "error"
      }
    }
  }
}