Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/57.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 未创建Laravel迁移表_Php_Mysql_Laravel 5 - Fatal编程技术网

Php 未创建Laravel迁移表

Php 未创建Laravel迁移表,php,mysql,laravel-5,Php,Mysql,Laravel 5,我是Laravel的新手。我按照教程创建了一个articles表。以下是我在/database/migrations/2017_02_13_145946_create_article_table.php中的部分代码 public function up() { // Schema::create('articles', function(Blueprint $table) { $table->increments('id'); $tabl

我是Laravel的新手。我按照教程创建了一个articles表。以下是我在/database/migrations/2017_02_13_145946_create_article_table.php中的部分代码

public function up()
{
    //
    Schema::create('articles', function(Blueprint $table)
    {
       $table->increments('id');
       $table->string('title');
       $table->text('body')->nullable();
       $table->integer('user_id');
       $table->timestamps();
    });
}
当我运行
php artisan migrate
时,表没有创建。我用谷歌搜索了这个问题,然后运行
php artisan migrate:reset
命令删除所有表。当我再次运行
php artisan migate
命令时,它显示

Migrated: 2014_10_12_000000_create_users_table
Migrated: 2014_10_12_100000_create_password_resets_table
Migrated: 2017_02_13_145946_create_article_table
但是没有创建任何内容,只更新了迁移记录表。表
user
password\u resets
也没有创建


你知道我做错了什么吗

我通常会尝试几种方法:

  • 在控制台中执行回滚,直到获得“无需回滚”为止:

    php artisan迁移:回滚

  • 然后,检查您的文章迁移文件并查找down函数(如果您没有,则需要添加它)

    public函数down()
    {
    //投递物品表
    Schema::drop('articles');
    }

  • 保存您的迁移文章文件(我知道这听起来很愚蠢,但我以前也遇到过这种情况)。我还建议更改文件名,从:

    2017_02_13_145946_create_article_table.php,至:

    2017_02_13_145946_创建文章\u table.php

  • 使用:

    composer转储自动加载

  • 转到您的数据库(本例中为laravel_db)并检查是否存在任何表(Mysql控制台):

    显示数据库;
    使用laravel_数据库:
    展示表格

  • 如果除了迁移之外没有任何表,请使用以下方法删除它:

    删除表迁移

  • 数据库为空后,从控制台运行迁移:

    php artisan迁移

  • 最后,如果没有发现错误,请检查创建的表(Mysql控制台):

    显示表格

  • 这是因为表列(值)长度默认为1071,mysql不接受 要清除此问题,请转到mysql并删除所有表。 转到应用程序(项目)文件夹=>app=>Providers

    在您的
    AppServiceProvider.php
    文件上写下这个

    //edit:yrs:- Needed for edit
    use Illuminate\Support\Facades\Schema;
    
    将其写入boot方法中

    //edit:yrs:-we can edit column sizefor tables here
    Schema::defaultStringLength(150);
    
    然后来到控制台并执行


    *命令/>
    php artisan migrate:status
    并查看运行状态为y或n(如果为n),然后执行

    *command />`php artisan migrate`
    
    *command />`php artisan migrate:status` and then 
    
    *command />`php artisan migrate:refresh` and then 
    
    *command />`php artisan migrate:status`
    

    这就是在mysql中创建表的所有步骤。如果显示迁移成功消息,则必须创建表,您是否检查了数据库中的迁移表以验证记录是否存在。@AkramWahid我已经检查了迁移表。列ID确实增加了。但是其他两个表没有生成。您能给我看一下迁移表的屏幕截图吗谢谢您的回复!我重新创建了这个项目,问题就解决了。