为什么php工匠什么都不迁移?

时间:2015-05-22 09:51:24

标签: php laravel migration migrate artisan

运行“php artisan migrate”什么都不做:没有数据库修改,没有消息(没有“无需迁移”),没有错误。

也没有记录表迁移。

以前,命令“php artisan migrate”工作正常。

文件夹数据库/迁移中的一个迁移文件具有以下内容:

<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class VidsTableEdit14 extends Migration {

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('vids', function(Blueprint $table)
        {
            //
            $table->integer('test');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('vids', function(Blueprint $table)
        {
            //
        });
    }

}

如何让“php artisan migrate”工作?

3 个答案:

答案 0 :(得分:1)

如果迁移突然停止,则某个迁移中可能存在语法错误。如果你突然得到一个没有找到的类错误,就会怀疑语法错误。

答案 1 :(得分:0)

当我试图在我的桌子上添加软删除时,我也发生了这种情况。

我创建了迁移,在Schema :: table函数中输入了“$ table-&gt; softDelete();”。而不是

$table->softDeletes();

注意复数的's',我尝试运行迁移,但没有收到任何错误或消息。我把它复数并且有效。

我注意到你没有记下功能()。尝试添加:

Schema::drop('vids');

再次运行迁移。

答案 2 :(得分:0)

错误:

SQLSTATE[42S01] 
Migrating: 2014_10_12_000000_create_users_table

   Illuminate\Database\QueryException 
-------------
[php artisan migrate] 

解决方案:转到:

app\Http\Providers\AppServiceProvider
import ( use Illuminate\Support\Facades\Schema; ) 

然后在register()函数内部,插入以下代码:

public function register()
{
     Schema::defaultStringLength(191); 
}

然后运行:

php artisan migrate:fresh