This is probably in another question, but I cannot find it.
I am a relative noobie to Rails. I am trying to add a new column to a table that already has data in it. This column is not going to allow nulls. What is the easiest way to update all the existing records to have a value in this new column? I know it is probably in the up block of my migration, but I don’t know what the syntax would be.
def self.up
change_table :reminders do |t|
t.boolean :active
end
#model name is Reminder - how to update data with a value?
end
What you can do is add the column, update all records in the table with the desired value, then change it to not allow nulls.