在Laravel 5中使用--force在生产中使用种子机进行数据库迁移 [英] Database gets stuck in migration with seeder on production with --force in Laravel 5
问题描述
在Laravel中使用--force在生产中使用发芽器进行数据库迁移时会陷入困境.我对运行Amazone linux的Laravel Homestead和EC2 AWS具有相同的效果. laravel.log中没有消息.
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.
它永远不会结束.如果我用<ctrl>+<c>
暂停了该程序,则可以看到该表已创建但未运行seeder,该表为空.
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.
狄塔里斯:
我的迁移:
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']);
}
我这样称呼它:
$ php artisan migrate --force
我的.env
#APP_ENV=local
APP_DEBUG=false
数据库种子.
class ProductsSeeder extends Seeder
{
public function run()
{
DB::table('products')->insert([
'id' => 1,
'name' => 'super product',
'price' => 999.99,
]);
}
经过Laravel 5.6测试
推荐答案
尝试在迁移命令中包含-vvv
标志,这将增加任何消息的详细程度,这可能会发现问题所在.
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)增加消息的详细程度:1表示正常输出,2表示更多详细输出,3表示调试
--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
对于问题本身,请尝试在db:seed
调用中包括--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,]);
这篇关于在Laravel 5中使用--force在生产中使用种子机进行数据库迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!