问题描述
|
我需要将一些列从一个现有表移动到另一表。如何使用Rails迁移进行操作?
class AddPropertyToUser < ActiveRecord::Migration
def self.up
add_column :users,:someprop,:string
remove_column :profiles,:someprop
end
def self.down
add_column :profiles,:string
remove_column :users,:someprop
end
end
上面只是创建了新列,但是值保留为空...
我想避免登录数据库以手动更新表。
如果可以通过编程方式移动列值,那么性能特征是什么?它会逐行执行,还是可以批量更新?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)