【发布时间】:2017-06-01 20:12:03
【问题描述】:
我正在做我的第一个 Laravel 项目。我正在尝试创建数据库迁移并使用artisan migrate 运行它们。迁移未运行,并且该命令不返回任何输出。
关键事实:
- 我使用
artisan make:migration创建了具有正确文件路径的迁移文件。 - 我第一次运行该命令时,它在数据库中创建了迁移表。所以我知道它正在访问数据库,并且至少做了一些正确的事情。
- 当
database/migrations文件夹中没有文件时,我会收到Nothing to migrate命令。 - 除了这两条消息之外,我根本没有收到命令的任何输出。没有错误,什么都没有。此外,数据库中的迁移表中没有记录。
-
artisan migrate --verbose也不返回任何输出。 -
storage/logs的权限是drwxrwxrwx.我是目录的所有者。 -
storage/logs/laravel.log不包含与迁移有关的任何内容。
我在下面包含了我第一次迁移的代码。
这个问题与this question 的不同之处在于之前的用户没有使用正确的命名约定。该问题包含有关迁移过程的详细答案。这没有帮助,因为我没有得到任何输出。在我输入此问题时,我还查看了 SO 建议的问题。
也许我的某些配置不正确?我需要做什么才能使这些迁移运行?
2017_01_17_151638_user.php
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
// Create the classes associated with user management.
class UserMigration extends Migration
{
public function up()
{
Schema::create('tblUser', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
Schema::create('tblUserPasswordReset', function (Blueprint $table) {
$table->string('email')->index();
$table->string('token')->index();
$table->timestamp('create_date')->nullable();
});
}
public function down()
{
Schema::dropIfExists('tblUserPasswordReset');
Schema::dropIfExists('tblUser');
}
}
【问题讨论】:
-
确保
/storage/logs文件夹是可写的;它可能会遇到错误并尝试将其记录在那里,并且根据您的开发环境,它可能无法正确通信。除此之外,可能还包括运行命令的终端的屏幕截图。 -
在我的例子中是 XDebug 监听和停止脚本。禁用侦听器后,该命令顺利通过。
标签: laravel laravel-migrations