如何解决Laravel Artisan migrate命令未在Homestead上运行
我最近刚刚在开发机器上安装了laravel homestead,一切都很顺利,我很喜欢。但是,我正在尝试使用迁移功能向现有表中添加一些列,但是运行php artisan migrate
命令时无法完成。它似乎已经开始,但即使离开超过10分钟也从未完成。
这是我的移民
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddColumnsToTransfersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('transfers',function (Blueprint $table) {
$table->integer('otp')->after('bank_code')->nullable();
$table->boolean('authorized')->after('otp')->nullable()->default('0');
$table->string('recipient_code')->after('authorized')->nullable();
$table->boolean('approval_required')->after('recipient_code')->nullable()->default('0');
$table->unsignedBigInteger('approved_by')->after('approval_required')->nullable();
$table->foreign('approved_by')->references('id')->on('users')->onDelete('set null');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('transfers',function (Blueprint $table) {
//
});
}
}
我知道数据库连接很好,因为我能够登录并从应用程序内部的数据库中提取数据。我能够使用php artisan make:migration
命令生成迁移文件,因此我不知道为什么在尝试运行实际迁移时似乎卡住了。
解决方法
似乎mysql服务有问题。因此,我通过运行sudo service mysql restart
停止了服务,然后运行php artisan migrate
,该表已成功迁移。问题解决了。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。