如何使用迁移重命名 laravel 中的列?
本文介绍了如何使用迁移重命名 laravel 中的列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有如下所述的列:
我已经为 stnk 表制作了播种机
现在我想将 id
重命名为 id_stnk
.
我在 "composer" 中添加了一个 "doctrine/dbal" 并进行了 composer update
.
Now I want to rename id
to id_stnk
.
I've added a "doctrine / dbal" in the "composer" and do a composer update
.
我做了迁移php artisan migration:make rename_column
.
然后我为 rename_column 添加了新方法:
I've made migration php artisan migration:make rename_column
.
Then I've added new method to rename_column:
然后我尝试运行命令 php artisan migrate
但出现如下错误:
And then I've tried to run command php artisan migrate
but I got error as mentioned bellow:
推荐答案
您需要创建另一个迁移文件 - 并将其放置在其中:
You need to create another migration file - and place it in there:
运行
然后在新的迁移文件里面放置:
Then inside the new migration file place:
这篇关于如何使用迁移重命名 laravel 中的列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!