Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nmenag/819b9755d902bfbfaea4e70ea57f0b84 to your computer and use it in GitHub Desktop.
Save nmenag/819b9755d902bfbfaea4e70ea57f0b84 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