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.
Asked
Active
Viewed 5,135 times
5
-
You can always `DB::raw()` http://stackoverflow.com/questions/5035836/how-to-add-auto-increment-to-an-existing-column – Jeremy Harris Jan 31 '17 at 21:33
2 Answers
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