summaryrefslogtreecommitdiff
path: root/db/migrate/20160416182152_convert_award_note_to_emoji_award.rb
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2016-06-13 14:15:11 +0200
committerYorick Peterse <yorickpeterse@gmail.com>2016-06-14 12:19:38 +0200
commitd032c6b0ff77a9a7568e1be8c728e252ddc1b11a (patch)
treeaf3efe2ded559e0acd33d8356bef77dffee9d50d /db/migrate/20160416182152_convert_award_note_to_emoji_award.rb
parentfc5b3a8fa51a4cbc116cc7e702602dd03cb726e1 (diff)
downloadgitlab-ce-d032c6b0ff77a9a7568e1be8c728e252ddc1b11a.tar.gz
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.
Diffstat (limited to 'db/migrate/20160416182152_convert_award_note_to_emoji_award.rb')
-rw-r--r--db/migrate/20160416182152_convert_award_note_to_emoji_award.rb7
1 files changed, 2 insertions, 5 deletions
diff --git a/db/migrate/20160416182152_convert_award_note_to_emoji_award.rb b/db/migrate/20160416182152_convert_award_note_to_emoji_award.rb
index 3906ab79398..6d57b796151 100644
--- a/db/migrate/20160416182152_convert_award_note_to_emoji_award.rb
+++ b/db/migrate/20160416182152_convert_award_note_to_emoji_award.rb
@@ -27,11 +27,8 @@ class ConvertAwardNoteToEmojiAward < ActiveRecord::Migration
end
def migrate_mysql
- execute <<-EOF
- lock tables notes WRITE, award_emoji WRITE;
- 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 '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);'
execute "DELETE FROM notes WHERE is_award = true"
remove_column :notes, :is_award, :boolean
ensure