Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make column auto incrementable with Laravel Migration

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.

like image 388
Sredny M Casanova Avatar asked Oct 17 '22 18:10

Sredny M Casanova


1 Answers

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.

like image 187
Erik Berkun-Drevnig Avatar answered Nov 02 '22 12:11

Erik Berkun-Drevnig