TIL in Rails: How to change column defaults with :from and :to option for making it a reversible migration

by @rinas

I was trying to change a column default 
def change
  change_column_default :blog, :language, "en_US"
end


and it gave this error when I try to rollback the migration
Caused by:
ActiveRecord::IrreversibleMigration:

change_column_default is only reversible if given a :from and :to optio
Learned that we can pass :from and :to option there. 


SOLUTION:

def change
  change_column_default :blog, :language, from: "en", to: "en_US"
end

Regarding privacy concerns, it's simple - we don't sell your data. In fact, we try to use privacy-focused software/services like Fathom Analytics whenever we use any third-party services.