I have several tables loaded with data, where many records have a status field of 0. I want to change them to 1. Is it possible to write a migration like this?
class UpdateStatusContent < ActiveRecord::Migration
def self.up
MiscDescription.where ["status = ?", 0].update ["status = ?", 1]
QuestionsBasic.where ["status = ?", 0].update ["status = ?", 1]
QuestionsStrength.where ["status = ?", 0].update ["status = ?", 1]
end
def self.down
end
end
I could do this directly in MySQL, but would prefer to use porting. I searched and experimented a bit and couldn't find a solution that works.
Thank you for your help.
source
share