Why does php artisan migrate nothing?

99封情书 提交于 2021-02-08 14:00:12

问题


Running "php artisan migrate" does nothing: no database modifications, no message(olso no "nothing to migrate"), no error.

No records are being added to table migrations as well.

Previously, the command "php artisan migrate" was working fine.

One of the migration files in folder database/migrations has this content:

<?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)
        {
            //
        });
    }

}

How to make "php artisan migrate" working?


回答1:


If the migration stops working suddenly there is probably a syntax error somewhere in one of your migrations. If you suddenly get a class not found error be suspicious of a syntax error.




回答2:


This same happened me, when I was trying to add soft delete to my table.

I created the migration and in the Schema::table function I typed "$table->softDelete();". Instead of

$table->softDeletes();

Notice the 's' for plural, I tried running migration and didn't get any error or message. I made it plural and it worked.

And I noticed that you didn't make down function().Try adding:

Schema::drop('vids');

And run the migration again.




回答3:


Error:

SQLSTATE[42S01] 
Migrating: 2014_10_12_000000_create_users_table

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

Solution: Go to:

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

And, inside the register() function, insert this code:

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

Then run:

php artisan migrate:fresh


来源:https://stackoverflow.com/questions/30393587/why-does-php-artisan-migrate-nothing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!