数据迁移脚本

 1 classes = %w(Call City Province Tag)

 2 classes.each do |obj_name|

 3   obj = Object.const_get(obj_name)

 4   obj.establish_connection :production

 5   models = obj.all.to_a

 6   obj.establish_connection :development

 7   ActiveRecord::Base.transaction do 

 8     models.each do |model|

 9       obj.create(model.attributes)

10     end

11   end

12 end

 

你可能感兴趣的:(数据迁移)