【发布时间】:2017-06-22 11:10:53
【问题描述】:
我只有一个新的迁移文件,即 2017_02_05_121119_create_posts_table.php,但是当我运行“php artisan migrate”时,它显示“[Symfony\Component\Debug\Exception\FatalErrorException] 无法重新声明类 CreateUsersTable”。
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePostsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('posts', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
$table->string('description');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('posts');
}
}
【问题讨论】:
-
做一件事,立即删除迁移表,然后再次触发 php artisan migrate 命令,它会起作用,但是您的表中是否有已经迁移的数据,然后备份它,然后清除您的数据库,然后运行命令
-
我也是这样做的,迁移创建成功,但是posts表没有创建
-
在您的问题中发布您的帖子迁移脚本,我敢肯定,该类名有问题
-
好的让我看看添加有问题的代码
-
请看代码