mysql - laravel 迁移增量列问题
问题描述
将我的 laravel 项目部署到云(heroku)后,我注意到当我尝试添加新用户或新角色或新东西时 .. 列 id 增加 +10 .. 例如第一个用户 id = 1 ,第二个用户 id = 11
例如这是我的角色表:
public function up()
{
Schema::create('roles', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name')->unique();
$table->timestamps();
});
}
解决方案
它与auto_increment_increment
mysql的设置有关。
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;
编辑:
由于 Heroku 使用cleardb
; 使用 cleardb 时无法更改它。这是带有解释的答案
推荐阅读
- python - 如何将具有坐标和频率的字典转换为矩阵?
- flutter - 如何在颤动中使用 DateFormat 选择出生日期?
- javascript - 从对象形成数据集
- python-2.7 - AWS Lambda 函数按标签调整实例大小
- python - python selenium chrome cookie 数据库为空
- node.js - Mongoose 分页速度太慢,无法查询数百条记录
- javascript - 谷歌标签管理器没有在子域上触发
- java - 使用 POI 麻烦将 DOCX 转换为 PDF
- javascript - 使用 projectPoints + solvePnP 的包装器构建 OpenCV.js
- ruby-on-rails - Rails 6:如何在演示者类中使用`button_to`?