无法删除 Laravel 5.3 中现有 table 的列?

Cannot drop column of existing table in Laravel 5.3?

我在 Laravel 5.3 中遇到问题。

它不允许我从现有 table 中删除一列。我有 运行 'composer require doctrine/dbal' 并且工作正常,但我的专栏不会删除。

我的add_column_to_table代码:

<?php

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

class AddColumnToTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('users', function (Blueprint $table)
        {
            $table->string('avatar')->default('default.pngs');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('users', function ($table)
        {
            $table->dropColumn('avatar');
        });
    }
}

谢谢

要删除列,您需要按以下方式回滚迁移

php artisan migrate:rollback

试试这个:

public function down()
{
    Schema::table('users', function (Blueprint $table)
    {
        $table->dropColumn('avatar');
     });
    }
}

您应该回滚您的迁移:

php artisan migrate:rollback

但请确保 table 上的该列为空。