Created
May 31, 2013 10:38
-
-
Save neaf/5684177 to your computer and use it in GitHub Desktop.
Deploy this initializer before migrations involving dropping/changing names of columns
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
model = MyModel | |
column_names = %w{ first_column second_column } | |
columns = model.columns.select { |c| column_names.include?(c.name) } | |
columns.each do |c| | |
model.columns.delete(c) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you just run migration with drop column statement ActiveRecord in your app instance will continue to issue queries with non-existing items in column list causing exceptions.
To avoid downtime deploy this initialzier before dropping columns.