Rules
Below the list of rules supported by the Postgres Language Server, divided by group. Here's a legend of the emojis:
- The icon ✅ indicates that the rule is part of the recommended rules.
Safety
Rules that detect potential safety issues in your code.
| Rule name | Description | Properties |
|---|---|---|
| addingFieldWithDefault | Adding a column with a DEFAULT value may lead to a table rewrite while holding an ACCESS EXCLUSIVE lock. | ✅ |
| addingForeignKeyConstraint | Adding a foreign key constraint requires a table scan and a SHARE ROW EXCLUSIVE lock on both tables, which blocks writes. | ✅ |
| addingNotNullField | Setting a column NOT NULL blocks reads while the table is scanned. | ✅ |
| addingPrimaryKeyConstraint | Adding a primary key constraint results in locks and table rewrites. | ✅ |
| addingRequiredField | Adding a new column that is NOT NULL and has no default value to an existing table effectively makes it required. | |
| banCharField | Using CHAR(n) or CHARACTER(n) types is discouraged. | |
| banConcurrentIndexCreationInTransaction | Concurrent index creation is not allowed within a transaction. | ✅ |
| banDropColumn | Dropping a column may break existing clients. | ✅ |
| banDropDatabase | Dropping a database may break existing clients (and everything else, really). | |
| banDropNotNull | Dropping a NOT NULL constraint may break existing clients. | ✅ |
| banDropTable | Dropping a table may break existing clients. | ✅ |
| banTruncateCascade | Using TRUNCATE's CASCADE option will truncate any tables that are also foreign-keyed to the specified tables. |
|
| changingColumnType | Changing a column type may break existing clients. | |
| constraintMissingNotValid | Adding constraints without NOT VALID blocks all reads and writes. | |
| disallowUniqueConstraint | Disallow adding a UNIQUE constraint without using an existing index. | |
| preferBigInt | Prefer BIGINT over smaller integer types. | |
| preferBigintOverInt | Prefer BIGINT over INT/INTEGER types. | |
| preferBigintOverSmallint | Prefer BIGINT over SMALLINT types. | |
| preferIdentity | Prefer using IDENTITY columns over serial columns. | |
| preferJsonb | Prefer JSONB over JSON types. | |
| preferRobustStmts | Prefer statements with guards for robustness in migrations. | |
| preferTextField | Prefer using TEXT over VARCHAR(n) types. | |
| preferTimestamptz | Prefer TIMESTAMPTZ over TIMESTAMP types. | |
| renamingColumn | Renaming columns may break existing queries and application code. | |
| renamingTable | Renaming tables may break existing queries and application code. | |
| requireConcurrentIndexCreation | Creating indexes non-concurrently can lock the table for writes. | |
| requireConcurrentIndexDeletion | Dropping indexes non-concurrently can lock the table for reads. | |
| transactionNesting | Detects problematic transaction nesting that could lead to unexpected behavior. |