Skip to content

Instantly share code, notes, and snippets.

@miligraf
Created December 8, 2016 01:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save miligraf/158324d23542c209f689feca29c1c89d to your computer and use it in GitHub Desktop.
Save miligraf/158324d23542c209f689feca29c1c89d to your computer and use it in GitHub Desktop.
class RenameReadColumToState < ActiveRecord::Migration
def change
add_column :messages, :state, :integer, default: 0
execute "UPDATE messages SET state = CAST(read AS INTEGER);"
remove_column :messages, :read
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment