【发布时间】:2015-07-27 04:46:09
【问题描述】:
我需要从 Laravel 迁移的表中删除一列。
通常的代码是:
$table->dropColumn([ 'city', 'country' ]);
但是你必须安装Doctrine DBAL 包才能使用dropColumn() 方法。
寻找另一种解决方案,我找到了removeColumn()方法(http://laravel.com/api/5.0/Illuminate/Database/Schema/Blueprint.html#method_removeColumn):
$table->removeColumn('city');
$table->removeColumn('country');
但似乎不起作用。它什么都不做,没有失败,并留下完整的列。
removeColumn 和 dropColumn 方法有什么区别?
removeColumn()方法有什么用?
【问题讨论】:
标签: database laravel database-migration