gpt4 book ai didi

laravel - 数据库在 Laravel 5 中使用 --force 进行生产时陷入迁移困境

转载 作者:行者123 更新时间:2023-12-02 10:08:10 25 4
gpt4 key购买 nike

在 Laravel 中使用 --force 进行生产时,数据库陷入迁移过程中。我对运行 Amazone linux 的 Laravel Homestead 和 EC2 AWS 也有同样的效果。 laravel.log 中没有消息。

它永远不会结束。如果我用 <ctrl>+<c> 停止它,我看到表已创建,但播种器未运行,表为空。

详情:

我的迁移:

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 标志,这会增加任何消息的详细程度,从而可能会发现问题。

--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 标志,因为您已将其包含在迁移中。

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

关于laravel - 数据库在 Laravel 5 中使用 --force 进行生产时陷入迁移困境,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50458656/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com