在将我的laravel项目部署到云(heroku)后,我注意到当我尝试添加新用户、新角色或新事物时。列id递增+10 ..例如,第一个用户id =1,第二个用户id = 11
例如,下面是my roles表:
public function up()
{
Schema::create('roles', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name')->unique();
$table->timestamps();
});
}
发布于 2020-05-17 10:37:10
与mysql的auto_increment_increment
设置有关。
mysql> SHOW VARIABLES LIKE 'auto_inc%';
+--------------------------+-------+
| Variable_name | Value |
+--------------------------+-------+
| auto_increment_increment | 1 |
| auto_increment_offset | 1 |
+--------------------------+-------+
2 rows in set (0.04 sec)
您的auto_increment_increment
可能设置为10。您可以通过执行重新设置为1;
SET @@auto_increment_increment=1;
请查看here
编辑:
因为Heroku使用的是cleardb
,所以不可能在使用cleardb的时候改变它。以下是explanation的答案
https://stackoverflow.com/questions/61845785
复制相似问题