All rules Rule BV044
note
hosted, paid — --remote

32-bit integer primary key headed for exhaustion

Note — this works and blocks nothing, but a performance regression is likely.

What it catches

An int primary key tops out at 2,147,483,647. Tables that get there discover it as an outage, and the fix — retyping the primary key and every referencing column — is one of the worst migrations there is. bigint costs 4 more bytes now and removes the cliff.

Fires on

CREATE TABLE orders (id serial PRIMARY KEY);

Do this instead

Make surrogate keys bigint from day one — 4 extra bytes per row against never having to retype a primary key and every foreign key that references it on a live system.

CREATE TABLE orders (
  id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY
);
Catch this before it ships

This rule runs in the hosted service on Startup and above — add --remote with a team token, or use the GitHub Action: npx bolvrk check migration.sql