laravel - 使用 Laravel 5 中的 --force 进行生产时,数据库卡在使用播种机迁移
问题描述
使用 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) 增加消息的详细程度:1 为正常输出,2 为更详细的输出,3 为调试
$ php artisan migrate --force
至于问题本身,请尝试--force
在调用中包含标志db:seed
,因为您已将其包含在迁移中。
Artisan::call('db:seed', ['--class' => 'ProductsSeeder', '--force' => true,]);
推荐阅读
- javascript - 为什么我的影子 dom 会破坏我的自定义元素?
- ruby-on-rails - 如何强制 Ruby 在 Net::HTTP 标头中遵守下划线
- loops - Shopify / Liquid - 产品标签 forloop 的输出顺序似乎是随机的?
- gradle - 当 2 个具有共享 .gradle 文件夹的分支并行运行时,Gradle 构建在 CI 中失败
- javascript - 单击后如何保持菜单中的项目被选中
- bash - 在 bash 中实现每组排序的最高值
- javascript - data.json() 不是函数(反应)
- java - 有没有其他方法可以将 LocalDateTime 转换为 OffsetDateTime (特定于时区)
- regex - BASH - 模式匹配问题
- python - Python 字典仅滚动浏览最后一个条目