gpt4 book ai didi

ruby-on-rails - 当我在 ruby​​ on rails 中生成迁移时,它会创建一个包含空方法的文件,为什么?

转载 作者:数据小太阳 更新时间:2023-10-29 07:57:15 25 4
gpt4 key购买 nike

我只是想重命名我的数据库中的列。当然,我只是删除数据库并进行更改然后迁移,但我想以更实用的方式进行。

我如何创建一个迁移来创建一个内部有正确信息的更改方法,所以我所要做的就是运行 rake db:migrate?

我正在运行的命令:

rails generate migration rename_column :profiles, :racial_background, :ethnicity

空方法:

class RenameColumn < ActiveRecord::Migration
def up
end

def down
end
end

亲切的问候

最佳答案

使用生成器只能暗示添加和删除列。

If the migration name is of the form “AddXXXToYYY” or “RemoveXXXFromYYY” and is followed by a list of column names and types then a migration containing the appropriate add_column and remove_column statements will be created.

Source

关于ruby-on-rails - 当我在 ruby​​ on rails 中生成迁移时,它会创建一个包含空方法的文件,为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8808777/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com