我在Laravel 5.3中遇到了问题。
它不允许我从现有表中删除列。我跑过作曲家需要学说/ 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');
});
}
}
由于
答案 0 :(得分:1)
要删除列,您需要以下列方式回滚迁移
php artisan migrate:rollback
答案 1 :(得分:0)
试试这个:
public function down()
{
Schema::table('users', function (Blueprint $table)
{
$table->dropColumn('avatar');
});
}
}
答案 2 :(得分:0)
您应该回滚迁移:
php artisan migrate:rollback
但请确保您的桌子上的列是空的。