我创建了一个 Laravel 项目并使用 Migrate 添加了几个表。一切都正常运行,这些表已经有了数据。现在我需要另一个表,并尝试使用以下命令添加:
php artisan make:migration create_books_table
它正在工作并在 \database\migrations 中添加文件... 然后我在up()函数中添加了模式。但当我运行命令时,
php artisan migrate
它无法工作,显示错误“基本表或视图已存在”。
请帮忙。我对Laravel非常陌生。谢谢。
迁移代码...
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateBooksTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('books', function(Blueprint $table)
{
$table->increments('id');
$table->string('name');
$table->text('description');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('books');
}
}
books
表或视图了,是吗?看起来一切都很正常。 - Ariful Haque