All rules
Schema
postgresql/
Prefer `bigint` for primary-key `id` columns; `int` overflows at 2.1B rows.
Why this matters
An `int` primary key overflows at ~2.1 billion rows. Widening the type later requires a table rewrite under `ACCESS EXCLUSIVE`. Declare the primary key as `bigint GENERATED ALWAYS AS IDENTITY` from the start. UUID primary keys and non-PK `id` columns are not flagged.
Examples
Incorrect
CREATE TABLE users (id int PRIMARY KEY, name text);CREATE TABLE users (id serial PRIMARY KEY, name text);CREATE TABLE users (id int, name text, PRIMARY KEY (id));Correct
CREATE TABLE users (id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name text);CREATE TABLE users (id uuid PRIMARY KEY, name text);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/prefer-bigint-id": "warn",
},
},
]; Options
Edit the SQL — only prefer-bigint-id 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
prefer-bigint-id — plus no-syntax-error as a safety net.