2 回答

TA貢獻1770條經驗 獲得超3個贊
我所做的就是轉到config文件夾然后database.php將 mysql 數據庫引擎從 null 更改為 innoDB 即來自:
//...
'engine' => null,
//...
到:
//...
'engine' => 'InnoDB',
//...

TA貢獻1848條經驗 獲得超10個贊
您用于Schema::create創建表。
在 Laravel 文檔中,我Schema::table在使用外鍵時看到。也許你應該嘗試拆分你的代碼:
Schema::create('articles', function (Blueprint $table) {
$table->id('id');
$table->unsignedBigInteger('user_id');
$table->string('title');
$table->text('excerpt');
$table->text('body');
$table->timestamps();
});
Schema::table('articles', function (Blueprint $table) {
$table->foreign('user_id')
->references('id')
->on('users')
->onDelete('cascade');
});
- 2 回答
- 0 關注
- 139 瀏覽
添加回答
舉報