Skip to content

Rules#

There are 100+ rules and all rules are enabled by default. Rule are divided into 7 categories:

  1. constraint: Rules for constraints
  2. general: Rules for best practice
  3. naming: Rules for naming
  4. schema: Rules for schema
  5. security: Rules for security
  6. typing: Rules for typing
  7. unsafe: Rules for unsafe migrations

constraint (CT)#

Code Name Stable Auto-fixable
CT001 cascade-update ✅ ✅
CT002 cascade-delete ✅ ✅
CT003 identity-generated-by-default ✅ ✅
CT004 remove-constraint ✅ ❌
CT005 duplicate-primary-key-column ✅ ✅
CT006 duplicate-unique-key-column ✅ ✅

general (GN)#

Code Name Stable Auto-fixable
GN001 table-inheritance ✅ ❌
GN002 create-rule ✅ ❌
GN003 sql-ascii-encoding ✅ ✅
GN004 missing-primary-key ✅ ❌
GN005 index-elements-more-than-three ✅ ❌
GN006 create-enum ✅ ❌
GN007 missing-replace-in-function ✅ ✅
GN008 missing-replace-in-procedure ✅ ✅
GN009 duplicate-column ✅ ❌
GN010 table-column-conflict ✅ ❌
GN011 missing-required-column ✅ ✅
GN012 required-column-removal ✅ ❌
GN013 nullable-required-column ✅ ✅
GN014 select-into ✅ ✅
GN015 drop-cascade ✅ ✅
GN016 constant-generated-column ✅ ❌
GN017 id-column ✅ ✅
GN018 multi-column-partitioning ✅ ❌
GN019 unlogged-table ✅ ✅
GN020 current-time ✅ ✅
GN021 null-constraint ✅ ✅
GN022 update-without-where-clause ✅ ❌
GN023 delete-without-where-clause ✅ ❌
GN024 null-comparison ✅ ✅
GN025 duplicate-index ✅ ❌
GN026 not-in ✅ ❌
GN027 yoda-condition ✅ ✅
GN028 asterisk ✅ ❌
GN029 missing-replace-in-view ✅ ✅
GN030 missing-replace-in-trigger ✅ ✅
GN031 stringified-null ✅ ✅
GN032 duplicate-index-column ✅ ✅
GN033 insert-without-target-columns ✅ ❌
GN034 typed-table ✅ ❌
GN035 inline-sql-function-body-wrong-language ✅ ✅

naming (NM)#

Code Name Stable Auto-fixable
NM001 invalid-index-name ✅ ❌
NM002 invalid-primary-key-name ✅ ❌
NM003 invalid-unique-key-name ✅ ❌
NM004 invalid-foreign-key-name ✅ ❌
NM005 invalid-check-constraint-name ✅ ❌
NM006 invalid-exclusion-constraint-name ✅ ❌
NM007 invalid-sequence-name ✅ ❌
NM008 implicit-constraint-name ✅ ❌
NM009 invalid-partition-name ✅ ❌
NM010 non-snake-case-identifier ✅ ❌
NM011 keyword-identifier ✅ ❌
NM012 special-character-in-identifier ✅ ❌
NM013 pg-prefix-identifier ✅ ❌
NM014 single-letter-identifier ✅ ❌
NM015 timestamp-column-without-suffix ✅ ✅
NM016 date-column-without-suffix ✅ ✅

schema (SM)#

Code Name Stable Auto-fixable
SM001 schema-unqualified-object ✅ ❌
SM002 disallowed-schema ✅ ✅

security (ST)#

Code Name Stable Auto-fixable
ST001 extension-whitelist ✅ ❌
ST002 procedural-language-whitelist ✅ ❌

typing (TP)#

Code Name Stable Auto-fixable
TP001 timestamp-without-timezone ✅ ✅
TP002 time-with-time-zone ✅ ✅
TP003 timestamp-with-timezone-with-precision ✅ ✅
TP004 char ✅ ✅
TP005 varchar ✅ ✅
TP006 money ✅ ✅
TP007 serial ✅ ✅
TP008 json ✅ ✅
TP009 integer ✅ ✅
TP010 smallint ✅ ✅
TP011 float ✅ ✅
TP012 xml ✅ ✅
TP013 hstore ✅ ✅
TP014 disallowed-data-type ✅ ✅
TP015 wrongly-typed-required-column ✅ ✅
TP016 numeric-with-precision ✅ ✅
TP017 nullable-boolean-field ✅ ✅

unsafe (US)#

Code Name Stable Auto-fixable
US001 drop-column ✅ ❌
US002 column-data-type-change ✅ ❌
US003 column-rename ✅ ❌
US004 adding-auto-increment-column ✅ ❌
US005 adding-auto-increment-identity-column ✅ ❌
US006 adding-stored-generated-column ✅ ❌
US007 drop-tablespace ✅ ❌
US008 drop-database ✅ ❌
US009 drop-schema ✅ ❌
US010 not-null-constraint-on-existing-column ✅ ❌
US011 not-null-constraint-on-new-column-with-volatile-default ✅ ❌
US012 validating-foreign-key-constraint-on-existing-rows ✅ ✅
US013 validating-check-constraint-on-existing-rows ✅ ✅
US014 unique-key-constraint-creating-index ✅ ❌
US015 primary-key-constraint-creating-index ✅ ❌
US016 non-concurrent-index-creation ✅ ✅
US017 index-movement-to-tablespace ✅ ❌
US018 indexes-movement-to-tablespace ✅ ❌
US019 non-concurrent-index-drop ✅ ✅
US020 non-concurrent-reindex ✅ ✅
US021 drop-table ✅ ❌
US022 rename-table ✅ ❌
US023 table-movement-to-tablespace ✅ ❌
US024 tables-movement-to-tablespace ✅ ❌
US025 cluster ✅ ❌
US026 vacuum-full ✅ ❌
US027 non-concurrent-detach-partition ✅ ✅
US028 non-concurrent-refresh-materialized-view ✅ ✅
US029 truncate-table ✅ ❌
US030 mismatch-column-in-data-type-change ✅ ❌