在 Laravel 5 中使用 --force 进行生产时,数据库卡在使用播种机的迁移中
Database gets stuck in migration with seeder on production with --force in Laravel 5
数据库在使用 Laravel 中的 --force 进行生产时使用播种器进行迁移。我对 Laravel Homestead 和 EC2 AWS 运行ning Amazone linux 也有同样的效果。 laravel.log.
中没有消息
它永远不会结束。如果我用 <ctrl>+<c>
停止它,我会看到创建了 table 但播种器不是 运行,table 是空的。
详细信息:
我的迁移:
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,]);
我有同样的问题 运行 php artisan migrate
但没有任何反应,一直卡住。
--force
或冗长无济于事。
我遇到的问题是 .env 中的 DB_PORT
设置不正确。
数据库在使用 Laravel 中的 --force 进行生产时使用播种器进行迁移。我对 Laravel Homestead 和 EC2 AWS 运行ning Amazone linux 也有同样的效果。 laravel.log.
中没有消息它永远不会结束。如果我用 <ctrl>+<c>
停止它,我会看到创建了 table 但播种器不是 运行,table 是空的。
详细信息:
我的迁移:
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,]);
我有同样的问题 运行 php artisan migrate
但没有任何反应,一直卡住。
--force
或冗长无济于事。
我遇到的问题是 .env 中的 DB_PORT
设置不正确。