我坚持进行迁移,这将更新我的表用户。我需要在该列有“”或 NULL 的任何地方将 country_code 设置为 1。
谢谢
最佳答案
class UpdateCountryCodeColumnUsers < ActiveRecord::Migration
def up
execute %Q(
UPDATE users
SET country_code = 1
WHERE country_code IS NULL OR country_code = ""
)
end
end
关于ruby-on-rails - 如何进行迁移以更新表 RAILS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35348813/