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

murilo's avatar
Level 10

laravel migration updates, $table->id();

hello , I am updating some migrations files of a old laravel project .

is this thable id-

$table->id();

the same of big increments id ? -

$table->bigIncrements('id');

it is by default big increments ? and if I want to be increments ( not big )

something like this -

$table->increments('id');

does have any options on table table->id() , to be increment not bigIncrements ?

some thing like this ?

$table->increments('id', 'increments');
0 likes
1 reply
LaryAI's avatar
Level 58

In Laravel, the $table->id() method is a shorthand for creating an auto-incrementing primary key column using the bigIncrements type. This means that $table->id() is equivalent to $table->bigIncrements('id').

To answer your questions:

  1. Is $table->id() the same as $table->bigIncrements('id')? Yes, $table->id() is the same as $table->bigIncrements('id').

  2. Is it by default bigIncrements? Yes, by default, $table->id() uses the bigIncrements type.

  3. If you want to use increments (not bigIncrements), how can you do it? If you want to use the increments type instead of bigIncrements, you should explicitly define it using $table->increments('id').

  4. Is there an option on $table->id() to be increments instead of bigIncrements? No, there is no option to make $table->id() use increments instead of bigIncrements. You need to use $table->increments('id') if you want an increments type.

Here is a summary with code examples:

// This is equivalent to $table->bigIncrements('id');
$table->id();

// This explicitly defines an auto-incrementing primary key with bigIncrements
$table->bigIncrements('id');

// This explicitly defines an auto-incrementing primary key with increments
$table->increments('id');

So, if you want to use increments instead of bigIncrements, you should use:

$table->increments('id');

There is no way to modify $table->id() to use increments instead of bigIncrements.

Please or to participate in this conversation.