Commit d032c6b0 authored by Yorick Peterse's avatar Yorick Peterse

Move LOCK TABLES to a separate execute

MySQL apparently doesn't support executing multiple queries in the same
`execute` call so we have to use a separate one for the "LOCK TABLES"
statement.
parent fc5b3a8f
...@@ -27,11 +27,8 @@ class ConvertAwardNoteToEmojiAward < ActiveRecord::Migration ...@@ -27,11 +27,8 @@ class ConvertAwardNoteToEmojiAward < ActiveRecord::Migration
end end
def migrate_mysql def migrate_mysql
execute <<-EOF execute 'LOCK TABLES notes WRITE, award_emoji WRITE;'
lock tables notes WRITE, award_emoji WRITE; execute 'INSERT INTO award_emoji (awardable_type, awardable_id, user_id, name, created_at, updated_at) (SELECT noteable_type, noteable_id, author_id, note, created_at, updated_at FROM notes WHERE is_award = true);'
INSERT INTO award_emoji (awardable_type, awardable_id, user_id, name, created_at, updated_at) (SELECT noteable_type, noteable_id, author_id, note, created_at, updated_at FROM notes WHERE is_award = true);
EOF
execute "DELETE FROM notes WHERE is_award = true" execute "DELETE FROM notes WHERE is_award = true"
remove_column :notes, :is_award, :boolean remove_column :notes, :is_award, :boolean
ensure ensure
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment