Menu
Squawk LogoSquawk LogoSquawkDocsRules
Quick StartGitHub
Squawk LogoSquawk LogoSquawk
  • Docs
  • Rules
  • Quick Start
  • GitHub
  • General
    • Quick Start
    • Applying migrations safely
    • CLI
    • GitHub Integration
    • Web Frameworks
    • Postgres locks and further reading
    • Troubleshooting
  • Rules
    • Rules Overview
    • adding-field-with-default
    • adding-foreign-key-constraint
    • adding-not-nullable-field
    • adding-serial-primary-key-field
    • ban-char-field
    • ban-drop-database
    • ban-drop-not-null
    • changing-column-type
    • constraint-missing-not-valid
    • disallowed-unique-constraint
    • prefer-big-int
    • prefer-bigint-over-int
    • prefer-bigint-over-smallint
    • prefer-identity
    • prefer-robust-stmts
    • prefer-text-field
    • prefer-timestamptz
    • renaming-column
    • renaming-table
    • require-concurrent-index-creation
    • require-concurrent-index-deletion
    • ban-drop-table

prefer-bigint-over-smallint

problem#

Using 16 bit integer fields can result in hitting the max int limit.

solution#

Use 64 bit integer field instead, like BIGSERIAL or BIGINT.

smallserial#

Instead of:

CREATE TABLE posts (
id smallserial primary key
)

Use:

CREATE TABLE posts (
id bigserial primary key
)

smallint#

Instead of:

CREATE TABLE posts (
id smallint primary key
)

Use:

CREATE TABLE posts (
id bigint primary key
)

related#

See "prefer-bigint-over-int" for a simliar lint rule against 32 bit integers.

Edit this page
Previous
« prefer-bigint-over-int
Next
prefer-identity »
  • problem
  • solution
    • smallserial
    • smallint
  • related

Docs

  • Quick Start
  • Rules

More

  • GitHub
  • Changelog
  • Help
Copyright © 2023 Squawk Authors.