首页 > 解决方案 > Laravel 迁移 - 将列放在另一列之前

问题描述

在 Laravel 中,我们有一个 after() 函数,它在给定列之后添加一列,例如:

  $table->string('address_line2')->after('address_line1');

我想添加一个 before () 函数,它将在给定列之前添加一列。我会很感激你的帮助。

标签: laravel

解决方案


There is no before() modifier after checking with the Laravel documentation. But you should know your fields in the table and its order so you can use after() modifier most of the time.

The only case that after() can't do is to add a field before the first field but there is first() modifier where you can put your field as the first field.


推荐阅读