我使用Laravel 5.2,有一個錯誤,當我運行php artisan migrate
,如下所示:Laravel 5.2:`PHP工匠migrate`的錯誤
2016_06_12_134655_create_categories_table.php
public function up() {
Schema::create('categories', function(Blueprint $table) {
$table->increments('id');
$table->string('category');
$table->timestamps();
});
}
2016_06_12_134659_create_goods_table .php
public function up() {
Schema::create('goods', function(Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('unit_price');
$table->integer('user_id')->unsigned();
$table->tinyInteger('category_id')->unsigned();
$table->foreign('user_id')->references('id')->on('users');
$table->foreign('category_id')->references('id')->on('categories');
$table->timestamps();
});
}
$ PHP工匠遷移
我該怎麼辦?
看來你'category_id'因爲沒有參考。你的分類表應該是第一個。 –