使用 Laravel 迁移使列自动递增
Make column auto incrementable with Laravel Migration
在laravel 5.2中是否可以修改一列使其成为auto_increment?我有一个 ID 列,它已经是主要的,但它不是 auto_increment,我需要制作它,我该怎么做?我在table里面有寄存器(每个都有对应的ID)所以我不能删除寄存器。
你试过change
方法了吗?
Schema::table('posts', function (Blueprint $table) {
$table->increments('id')->change();
});
有关详细信息,请参阅 changing columns 上的文档部分。
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');
});
在laravel 5.2中是否可以修改一列使其成为auto_increment?我有一个 ID 列,它已经是主要的,但它不是 auto_increment,我需要制作它,我该怎么做?我在table里面有寄存器(每个都有对应的ID)所以我不能删除寄存器。
你试过change
方法了吗?
Schema::table('posts', function (Blueprint $table) {
$table->increments('id')->change();
});
有关详细信息,请参阅 changing columns 上的文档部分。
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');
});