diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2016-06-13 14:15:11 +0200 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2016-06-13 14:15:11 +0200 |
commit | d5a18a6c55bf6c427536c185d66e339766843100 (patch) | |
tree | 41893f2897b1f38e847b3c8666f6aee22d5251c7 | |
parent | 2ac146d6d8bb221a2594e7a8b941d5a628b5ffb8 (diff) | |
download | gitlab-ce-zj-rework-migration-award-emoji.tar.gz |
Move LOCK TABLES to a separate executezj-rework-migration-award-emoji
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.
-rw-r--r-- | db/migrate/20160416182152_convert_award_note_to_emoji_award.rb | 7 |
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 13b47713137..822e7a3eff4 100644 --- a/db/migrate/20160416182152_convert_award_note_to_emoji_award.rb +++ b/db/migrate/20160416182152_convert_award_note_to_emoji_award.rb @@ -26,11 +26,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 |