【问题标题】:Laravel migrate:refresh Doesn't Work After Composer UpdateLaravel migrate:refresh 在 Composer 更新后不起作用
【发布时间】:2019-05-05 05:16:29
【问题描述】:

标题中的命令返回如下错误信息:

类型错误:函数的参数太少 Illuminate\Database\Schema\Builder::create(), 1 传入 C:\xampp7\htdocs\assurance-web\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php 在第 221 行,预计正好 2 行

我使用以下命令安装了框架:

composer create-project --prefer-dist laravel/laravel assurance-web
version 5.7

然后执行:

php artisan make:migration create_banks_table --create=banks

我能够毫无错误地运行php artisan migrate。但是,当我运行 php artisan migrate:refresh 时,我得到了上面的错误。

这是“2018_12_04_033726_create_table_banks.php”:

<?php

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

class CreateBanksTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('banks', function(Blueprint $table) {
            $table->increments('id');
            $table->string('bank_name');
            $table->string('bank_code');
            $table->timestamps();
        });
    }

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

【问题讨论】:

  • 这会在运行任何迁移之前显示特定错误。如果您只使用php artisan config:cache 或任何其他工匠命令,您仍然会收到此错误。它与migrate 无关。它只是说先修复该错误。
  • 这也可能不在那个文件中。
  • 查看storage/logs文件夹中的错误日志文件,您会找到源代码。

标签: php laravel laravel-artisan laravel-migrations artisan-migrate


【解决方案1】:

可能您的迁移表已被盗用。 您可以使用:

php artisan migrate:fresh

而不是“php artisan migrate:refresh”,迁移会看到它会起作用。

“php artisan migrate:fresh”命令物理删除所有表而不是回滚。

【讨论】:

    猜你喜欢
    • 2016-07-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-27
    • 2014-11-11
    • 2016-10-24
    • 2016-12-07
    • 1970-01-01
    相关资源
    最近更新 更多