【发布时间】:2017-03-31 03:38:49
【问题描述】:
我在 Laravel 5.3 中遇到问题。
它不允许我从现有表中删除列。我已经运行了“composer 需要学说/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');
});
}
}
谢谢
【问题讨论】:
-
你看到了什么错误
-
改用
removeColumn()。 -
不确定这是否会有所不同,但我认为您在添加(或修改)列时通常不会使用
Blueprint。 -
@user2693928 -- 没有错误,该列没有删除
标签: php database laravel migration laravel-5.3