2

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

Yevgeniy Afanasyev
  • 37,872
  • 26
  • 173
  • 191

2 Answers2

6

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,]);

Jeemusu
  • 10,415
  • 3
  • 42
  • 64
1

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.

antoni
  • 5,001
  • 1
  • 35
  • 44