【发布时间】:2019-06-26 06:30:02
【问题描述】:
我现在正在开发一个 Laravel 应用程序,但是当我现在运行 php artisan migrate 时,突然之间我总是得到错误:
SQLSTATE[HY000]: General error: 1364 Field 'id' doesn't have a default value (SQL: insert into `migrations` (`migration`, `batch`) values (2019_06_05_080701_create_departments_table, 22))
我不知道为什么会发生这种情况,因为以前从未发生过。当我尝试迁移特定迁移时,我得到了同样的错误,那么这里发生了什么?
迁移如下所示:
public function up()
{
Schema::create('departments', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('company_id');
$table->string('name');
$table->string('p_number')->nullable();
$table->string('address')->nullable();
$table->string('zipcode')->nullable();
$table->string('city')->nullable();
$table->string('contact_name')->nullable();
$table->string('contact_email')->nullable();
$table->string('contact_phone')->nullable();
$table->timestamps();
});
}
SHOW COLUMNS FROM migrations;的结果
【问题讨论】:
-
您自己创建了迁移表吗?
-
请向我们展示该迁移的代码。
-
@MagnusEriksson 请检查我更新的问题 :-) 无论如何,它在每次迁移中......
-
@DrakulaPredator 不,这就是奇怪的部分......
-
同意@DrakulaPredator。 @ST80 你能显示
SHOW COLUMNS FROM migrations;的结果吗?