Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

kendrick's avatar

Difference between increments, and bigIncrements?

Hello, quick question:

What is the fundamental difference between:

$table->bigIncrements('id');

and

$table->increments('id');
0 likes
8 replies
lucijaz's avatar
lucijaz
Best Answer
Level 4

$table->bigIncrements('id'); = Auto-incrementing UNSIGNED BIGINT (primary key) equivalent column.

$table->increments('id'); = Auto-incrementing UNSIGNED INTEGER (primary key) equivalent column.

check: https://laravel.com/docs/5.8/migrations

Difference between integer and bigint:

INT[(M)] [UNSIGNED] [ZEROFILL]

A normal-size integer. The signed range is -2147483648 to 2147483647. The unsigned range is 0 to 4294967295.

BIGINT[(M)] [UNSIGNED] [ZEROFILL]

A large integer. The signed range is -9223372036854775808 to 9223372036854775807. The unsigned range is 0 to 18446744073709551615.

10 likes
kuns25's avatar

but why bigint by default most of time we will never have this much value or records

1 like
carlosmora's avatar

Is there any way to change the bahavoir of make:migrations to use 'increments' instead of 'bigIncrements'?

gbaggaley's avatar

Yeah, is there any performance improvement with using normal increments instead of bigIncrements? If not, there's not really much point in using just increments because you're just limiting yourself to using a smaller range of numbers.

dadub's avatar

Hi, why have I this as default ? :

$table->id();

Is this the same as $table->bigIncrements('id'); ?

Thank you for your help.

burakcalik's avatar

@kuns25 I said the same thing when we first start a saas application 5 years ago, now we have to convert that large db to bigIntegers, which will probably take a week to migrate. In order to keep application running without any downtime, instead of converting table I have to create a new table, then copy all data from old to new table, and save the new data to both tables, and keep copying all old data slowly.

So my suggestion for you that, do yourself a favor and just use big integers :)

6 likes

Please or to participate in this conversation.