diff --git a/db/post_migrate/20210207232853_fix_topic_timer_duration_minutes.rb b/db/post_migrate/20210207232853_fix_topic_timer_duration_minutes.rb new file mode 100644 index 00000000000..a10aa00fc3d --- /dev/null +++ b/db/post_migrate/20210207232853_fix_topic_timer_duration_minutes.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true +class FixTopicTimerDurationMinutes < ActiveRecord::Migration[6.0] + def up + DB.exec("UPDATE topic_timers SET duration_minutes = (duration * 60 * 24) WHERE duration_minutes IS NULL AND status_type = 7 AND duration IS NOT NULL") + DB.exec("UPDATE topic_timers SET duration_minutes = (duration * 60) WHERE duration_minutes IS NULL AND status_type != 7 AND duration IS NOT NULL") + end + + def down + raise ActiveRecord::IrreversibleMigration + end +end