php artisan migrate没有做任何事情

问题描述 投票:1回答:1

我在我的Macbook Pro(运行High Sierra(10.13.6))上使用Homebrew安装了Laravel 5和Valet(v2.0.12)。我已经下载了一个干净的Laravel项目(laravel new blog)。

当我尝试迁移(坐在项目文件夹中,然后使用php artisan migrate)时,没有任何反应。终端只是坐在那里什么都不做。命令正在执行,但什么都没有。没有错误,没有成功,没有。即使添加-v也没有。

我可以通过命令行进入服务器。我在.env文件中输入了正确的凭据。我甚至可以运行其他php artisan命令,但所有migrate命令都没有做任何事情。

我的迁移文件是:

2018_09_04_100609_create_users_table.php

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('email')->unique();
            $table->string('password');
            $table->rememberToken();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}

2018_09_04_100659_create_password-resets_table.php

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreatePasswordResetsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('password_resets', function (Blueprint $table) {
            $table->string('email')->index();
            $table->string('token');
            $table->timestamp('created_at')->nullable();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('password_resets');
    }
}

更新:

使用以下内容检查数据库连接:

try {
    DB::connection();
    die("success!");
} catch (\Exception $e) {
    die("Could not connect to the database.  Please check your configuration. error:" . $e );
}

我得到了“成功!”。

但后来我将DB::connection()改为DB::connection()->getPdo()它再也没有做任何事情。或者那不相关?

php laravel artisan artisan-migrate
1个回答
0
投票

我修好了。之后我会添加很多惊叹号,但我不喜欢它。为什么?

因为问题是我使用的是MySQL,而我应该一直在使用MariaDB。该指南没有提到任何地方,所以我只是假设MySQL已经足够了。显然不是。如果错误显示出类似的东西,那会很好吗......

© www.soinside.com 2019 - 2024. All rights reserved.