All rules
Safety
postgresql/
Warn on `DROP NOT NULL` — surprises consumers that already assume non-null.
Why this matters
Relaxing the constraint lets the column store NULLs again. Every reader that already assumes the column is non-null (joins, COALESCE coverage, app-level types) silently breaks. Model the truly optional case explicitly instead.
Examples
Incorrect
ALTER TABLE users ALTER COLUMN email DROP NOT NULL;Correct
ALTER TABLE users ALTER COLUMN status DROP DEFAULT;Configure it
// eslint.config.js
import postgresql from "eslint-plugin-postgresql";
export default [
{
files: ["**/*.sql"],
languageOptions: {
parser: postgresql.configs.recommended.languageOptions.parser,
},
plugins: { postgresql },
rules: {
"postgresql/no-drop-not-null": "warn",
},
},
]; Options
Edit the SQL — only no-drop-not-null is enabled.
Pre-filled with the first incorrect example. Toggle off in the rule shelf to see how the diagnostic disappears.
Diagnostics
No issues found.
2 rules enabled.
Rule under test
no-drop-not-null — plus no-syntax-error as a safety net.