Database gets stuck in migration with seeder on production with --force in Laravel 5

 ̄綄美尐妖づ 提交于 2019-11-28 05:42:18

问题


Database gets stuck in migration with seeder on production with --force in Laravel. Same effect I have on Laravel Homestead and EC2 AWS running Amazone linux. No messages in laravel.log.

It just never ends. If I halt it with <ctrl>+<c>, I see the table created but seeder was not run, the table is empty.

Detalis:

My migration:

public function up()
{
    Schema::create('products', function (Blueprint $table) {
        $table->increments('id');
        $table->string('name', 50);
        $table->decimal('price', 8, 2); //up to 999,999.99
    });

    Artisan::call('db:seed', ['--class' => 'ProductsSeeder']);
}

I call it like so:

$ php artisan migrate --force

my .env

#APP_ENV=local

APP_DEBUG=false

the database seeds.

class ProductsSeeder extends Seeder
{
    public function run()
    {
        DB::table('products')->insert([
            'id'                   => 1,
            'name'                 => 'super product',
            'price'                => 999.99,
        ]);
    }

Tested Laravel 5.6


回答1:


Try including the -vvv flag in your migration command, this will increase the verbosity of any messages, which might uncover the problem.

--verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

$ php artisan migrate --force

As for the problem itself, try including the --force flag in your db:seed call, as you have included it in the migration.

Artisan::call('db:seed', ['--class' => 'ProductsSeeder', '--force' => true,]);




回答2:


I had same issue running php artisan migrate and nothing happens, stays stuck. --force or verbose wouldn't help.

The problem I had is the DB_PORT in .env was not set correctly.



来源:https://stackoverflow.com/questions/50458656/database-gets-stuck-in-migration-with-seeder-on-production-with-force-in-larav

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