A platform for community discussion. Free, open, simple.
FIX: check for existing translation keys before replacing blocked with silenced
Arpit Jalan84026ad1fdbd
diff --git a/db/migrate/20171228122834_replace_blocked_silence_translation.rb b/db/migrate/20171228122834_replace_blocked_silence_translation.rbindex 06ce33ed13f..dfd9a02c0ff 100644--- a/db/migrate/20171228122834_replace_blocked_silence_translation.rb+++ b/db/migrate/20171228122834_replace_blocked_silence_translation.rb@@ -1,8 +1,17 @@class ReplaceBlockedSilenceTranslation < ActiveRecord::Migration[5.1]def changeexecute <<~SQL- UPDATE translation_overrides SET translation_key = 'system_messages.silenced_by_staff.subject_template' WHERE translation_key = 'system_messages.blocked_by_staff.subject_template';- UPDATE translation_overrides SET translation_key = 'system_messages.silenced_by_staff.text_body_template' WHERE translation_key = 'system_messages.blocked_by_staff.text_body_template';+ UPDATE translation_overrides+ SET translation_key = 'system_messages.silenced_by_staff.subject_template'+ WHERE translation_key = 'system_messages.blocked_by_staff.subject_template'+ AND NOT EXISTS (SELECT 1 FROM translation_overrides WHERE translation_key = 'system_messages.silenced_by_staff.subject_template');+ SQL++ execute <<~SQL+ UPDATE translation_overrides+ SET translation_key = 'system_messages.silenced_by_staff.text_body_template'+ WHERE translation_key = 'system_messages.blocked_by_staff.text_body_template'+ AND NOT EXISTS (SELECT 1 FROM translation_overrides WHERE translation_key = 'system_messages.silenced_by_staff.text_body_template');SQLendend