From 410e41e53c61e8bf1a3a6b6d19463eadbdd7edbc Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 26 Sep 2017 14:22:38 +0200 Subject: [PATCH] Do not execute callbacks whiling migration (do not send ne call events to clients). --- db/migrate/20170905140038_cti_log_preferences_migration.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/db/migrate/20170905140038_cti_log_preferences_migration.rb b/db/migrate/20170905140038_cti_log_preferences_migration.rb index de4a70eea..16c0c3a67 100644 --- a/db/migrate/20170905140038_cti_log_preferences_migration.rb +++ b/db/migrate/20170905140038_cti_log_preferences_migration.rb @@ -33,6 +33,7 @@ end class CtiLogPreferencesMigration < ActiveRecord::Migration[5.0] def change + # correct all entries Cti::Log.all.pluck(:id).each do |item_id| item = Cti::Log.find(item_id) @@ -40,6 +41,7 @@ class CtiLogPreferencesMigration < ActiveRecord::Migration[5.0] next if item.preferences.blank? # check from and to keys which hold the instances + preferences = {} %w(from to).each do |direction| next if item.preferences[direction].blank? @@ -51,11 +53,11 @@ class CtiLogPreferencesMigration < ActiveRecord::Migration[5.0] end # overwrite the old key with the converted data - item.preferences[direction] = updated + preferences[direction] = updated end # update entry - item.save! + item.update_column(:preferences, preferences) end end end