5

In laravel 5.2 is possible to modify a column to make it auto_increment? I have an ID column, its primary already, but it's not auto_increment, and I need to make it, how can I do it? I have registers in the table (each of them have the corresponding ID) so I cannot delete the registers.

Sredny M Casanova
  • 4,735
  • 21
  • 70
  • 115

2 Answers2

3

Did you try the change method?

Schema::table('posts', function (Blueprint $table) {
    $table->increments('id')->change();
});

See the documentation section on changing columns for more info.

Erik Berkun-Drevnig
  • 2,306
  • 23
  • 38
0

Before modifying a column, be sure to add the doctrine/dbal dependency to your composer.json file. Here is the documentation

 Schema::table('users', function ($table) {
        $table->bigIncrements('id');
    });
Sanzeeb Aryal
  • 4,358
  • 3
  • 20
  • 43