从Laravel Migration迁移表时出现此错误
Schema::create('galleries', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('title');
$table->text('images');
$table->timestamps();
});
这是我终端中出现的全部错误:
Illuminate\Database\QueryException : SQLSTATE[HY000]: General error: 1364 Field 'id' doesn't have a default value (SQL: insert into `migrations` (`migration`, `batch`) values (2019_11_10_143218_create_galleries_table, 2))
at /var/www/html/example.com/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
660| // If an exception occurs when attempting to run a query, we'll format the error
661| // message to include the bindings with SQL, which will make this exception a
662| // lot more helpful to the developer instead of just the database's errors.
663| catch (Exception $e) {
Exception trace:
1 PDOException::("SQLSTATE[HY000]: General error: 1364 Field 'id' doesn't have a default value")
/var/www/html/example.com/vendor/laravel/framework/src/Illuminate/Database/Connection.php:458
2 PDOStatement::execute()
/var/www/html/example.com/vendor/laravel/framework/src/Illuminate/Database/Connection.php:458
Please use the argument -v to see more details.
答案 0 :(得分:0)
您试图在db中添加未传递ID的行,并且未将db表ID设置为自动生成。