我需要将迁移列类型为$table->string('text');更改为文本类型,我尝试了几种方法来实现此目的,但是它们都没有起作用.是否可以在一次迁移中做到这一点.我想我可以删除该列,然后使用新类型再次创建它,但是我想知道是否可以在一次迁移中做到这一点?
I need to change with migration column type of $table->string('text'); to a text type, I have tried to do that in few ways, but none of them worked. Is it possible to do it in one migration. I could I guess drop the column and then create it again with new type, but I wonder if it is possible to do it in one migration?
推荐答案您可以创建新的迁移,并仅更改一种列类型:
You can create a new migration and change just one column type:
public function up() { Schema::table('sometable', function (Blueprint $table) { $table->text('text')->change(); }); }您需要安装doctrine/dbal才能使其正常工作
You need to install doctrine/dbal to make this work
composer require doctrine/dbal可与Laravel 5.0及更高版本一起使用.它不适用于Laravel 4.2.
Works with Laravel 5.0+. It does not work with Laravel 4.2.
更多推荐
Laravel迁移将列类型从varchar更改为longText
发布评论