Php laravel不创建新表

Php laravel不创建新表,php,laravel-5,Php,Laravel 5,我只有一个新的迁移文件,即2017_02_05_121119_create_posts_table.php,但当我运行“php artisan migrate”时,它会说“[Symfony\Component\Debug\Exception\FatalErrorException]无法重新声明类CreateUsersTable” 您是否已为此迁移进行了复制/粘贴?看起来您留下了previus类的类名,因为种子是create posts,但类创建用户。编辑AppServiceProvider.ph

我只有一个新的迁移文件,即2017_02_05_121119_create_posts_table.php,但当我运行“php artisan migrate”时,它会说“[Symfony\Component\Debug\Exception\FatalErrorException]无法重新声明类CreateUsersTable”


您是否已为此迁移进行了复制/粘贴?看起来您留下了previus类的类名,因为种子是create posts,但类创建用户。

编辑AppServiceProvider.php并包含“use-illumb\Support\Facades\Schema”;然后在引导方法中添加这一行“Schema::defaultStringLength(191);”

在Providers文件夹中编辑AppServiceProvider.php文件

您只需添加以下两行:

use Illuminate\Support\Facades\Schema;
在启动功能中:

 Schema::defaultStringLength(191);

做一件事,立即删除迁移表,然后再次启动php artisan migrate命令,它会工作,但是您的表中是否有已经迁移的数据,然后对其进行备份,然后清除数据库,然后运行命令我也这么做了,迁移已成功创建,但posts表未创建您的post迁移脚本。在您的问题中,我确信,该类名存在问题。好的,让我看看添加问题中的代码。请查看代码。我收到了,谢谢@Rocco。我已更改了类名,但出现了其他问题。。。现在显示为[PDOException]SQLSTATE[42S01]:基本表或视图已经存在:1050表“用户”已经存在。在迁移的第一行上没有创建新的表名。您必须将表名从user更改为postst此文件正常,但当您开始迁移时,如果迁移结束时出现错误,则可能会发生迁移表中未将其设置为don的情况。因此,它看起来像是在尝试重新创建已存在的用户表。尝试手动删除整个数据库并重新进行迁移
 Schema::defaultStringLength(191);