我只有一个新的迁移文件,它是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');
}
}
发布于 2017-02-06 00:02:35
编辑AppServiceProvider.php并包括“使用照明\支持\外观\架构;”,然后在引导方法中添加以下行:“架构::默认字符串长度(191);”
发布于 2017-02-05 20:32:46
您是否对此迁移进行了复制/粘贴?看起来您留下了前一个的类名,因为种子是create post,而类是create users。
发布于 2018-06-07 05:17:03
在Providers文件夹中,编辑AppServiceProvider.php文件。
您只需要在其中添加以下两行:
use Illuminate\Support\Facades\Schema;
在引导函数中:
Schema::defaultStringLength(191);
https://stackoverflow.com/questions/42052048
复制相似问题