FIX: Delete topic timers far in the future ()

The migration used to fail because the same duration in minutes was out
of the integer range. The '20 years' limit was introduced in e0f0fe5.
This commit is contained in:
Dan Ungureanu 2021-02-18 14:18:43 +02:00 committed by GitHub
parent 13d2a1f82c
commit bddf94c0ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,6 +1,9 @@
# frozen_string_literal: true
class FixTopicTimerDurationMinutes < ActiveRecord::Migration[6.0]
def up
DB.exec("DELETE FROM topic_timers WHERE status_type = 7 AND duration > 20 * 365")
DB.exec("DELETE FROM topic_timers WHERE status_type != 7 AND duration > 20 * 365 * 24")
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