Skip to content

SERIAL/BIGSERIAL/SMALLSERIAL columns #94

@ayarotsky

Description

@ayarotsky

SERIAL and its variants are pseudo-types that are not standard SQL. They have known issues with permission management (the sequence is owned separately), pg_dump behavior, and logical replication. PostgreSQL 10 introduced GENERATED BY DEFAULT AS IDENTITY as the standard replacement.

  -- Flagged
  CREATE TABLE events (id BIGSERIAL PRIMARY KEY);

  -- Safe alternative
  CREATE TABLE events (id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY);

Note: diesel-guard already has AddSerialColumnCheck which flags ALTER TABLE ADD COLUMN ... SERIAL. This new check would cover CREATE TABLE as well and expand the recommendation to prefer identity columns.

Review the Contribution Guide before adding a new check. It covers the architecture, implementation patterns, and step-by-step instructions.

Metadata

Metadata

Assignees

Labels

Projects

Status

In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions