最近,我们对服务提供程序进行了切换,以便将此项目的DB表中的多个列重新命名。
我知道this post,它展示了如何从1个表中重命名1列:
php artisan migrate:make rename_stk_column --table="YOUR TABLE" --create有办法用多列执行相同的迁移吗?(1次迁移,不超过1...trying,以减少所创建的迁移文件的数量)
发布于 2016-06-10 20:57:41
您可以为需要在给定表中更新的每个列添加多个renameColumn();语句。只需要想出一个你们的家伙/女孩们在迁移文件中使用的名字。
只是我运行的一个样本
class MultipleColumnUpdate extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('users', function ($table) {
            $table->renameColumn('name', 'user_name');
            $table->renameColumn('email', 'work_email');
        });
    }
    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('users', function ($table) {
            $table->renameColumn('user_name', 'name');
            $table->renameColumn('work_email', 'email');
        });
    }
}https://stackoverflow.com/questions/37756741
复制相似问题