value "3000000000" is out of range for type integer

Laravel app, just moved from MySQL to PostgreSQL. The full message as Laravel shows it:

SQLSTATE[22003]: Numeric value out of range: 7 ERROR: value "3000000000" is out of range for type integer

Why it happens

Postgres has no unsigned integers. Laravel's unsignedInteger() and increments() become a plain integer on pgsql, so the ceiling drops from 4,294,967,295 to 2,147,483,647. Values above that loaded fine on MySQL and fail on Postgres.

Fix

ALTER TABLE events ALTER COLUMN hits TYPE bigint; -- in Laravel migrations: unsignedBigInteger() / bigIncrements() instead of -- unsignedInteger() / increments()

Tested with Laravel 13 on MariaDB 11.8 + Postgres 17: inserting 3000000000 works on MariaDB and fails on Postgres with SQLSTATE[22003]; after ALTER ... TYPE bigint it works.

The tested fix for every table at once (scripts, a Laravel command, before/after checks): Laravel Postgres Error Fix Pack ($19), item 06.

Several errors at once? Paste your log into the error matcher. Raw SQL with MySQL syntax: the free SQL translator. Not migrated yet: the free schema risk check finds this kind of problem before the switch. Planning the whole move: Migration Kit ($49, $34.30 with LAUNCH30 until Nov 5).

Other errors after MySQL to Postgres

Published with deed.page