爲什麼不能,而且看起來沒什麼可遷移的?沒什麼可遷移的laravel 4.2
當遷移創建表的作者和書都可以,但外鍵後不能
遷移添加外:
public function up()
{
Schema::table('books', function(Blueprint $table) {
$table->foreign('author_id')->references('id')->on('authors')
->onDelete('restrict')
->onUpdate('cascade');
});
}
使用本:
php artisan migrate
與此:
php artisan migrate --path=app/database/migrations/2016_07_11_105204_add_foreign_key_to_books.php
仍不能,
表的書:
public function up()
{
Schema::create('books', function(Blueprint $table) {
$table->increments('id');
$table->string('title');
$table->integer('author_id')->unsigned();
$table->integer('amount')->unsigned();
$table->timestamps();
});
}
表作者:
public function up()
{
Schema::create('authors', function(Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->timestamps();
});
}
感謝您的幫助..
如果您手動添加了遷移,請嘗試使用'composer dumpautoload'來識別它。 –