我创建了一个迁移脚本,用于创建一个名为Archives的表.
它有4列不包括时间戳/增量.表格列是名称,标题,内容和图像.
我需要删除不再需要的图像列.
我无法通过搜索找到一种方法来做到这一点,并希望有人能给我最好的方法来做到这一点.
我尝试通过创建新的迁移然后运行来实现此目的
php artisan migrate:rollback --pretend
但这会尝试回滚先前的迁移.
class DropImageColumnArchive extends Migration { /** * Run the migrations. * @return void */ public function up() { Schema::table('archives', function ($table) { $table->text('image'); }); } /** * Reverse the migrations. * @return void */ public function down() { Schema::table('archives', function ($table) { $table->drop_column('image'); }); } }
Jonny C.. 18
几乎将drop_column更改为dropColumn
参考 http://laravel.com/docs/schema#renaming-columns
Schema::table('users', function($table) { $table->dropColumn('votes'); });
编辑此处参考5.1 http://laravel.com/docs/5.1/migrations
几乎将drop_column更改为dropColumn
参考 http://laravel.com/docs/schema#renaming-columns
Schema::table('users', function($table) { $table->dropColumn('votes'); });
编辑此处参考5.1 http://laravel.com/docs/5.1/migrations