mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 11:11:13 +08:00
FIX: Backfill topic timer duration (#9249)
This commit is contained in:
20
db/migrate/20200320193612_back_fill_topic_timer_durations.rb
Normal file
20
db/migrate/20200320193612_back_fill_topic_timer_durations.rb
Normal file
@ -0,0 +1,20 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class BackFillTopicTimerDurations < ActiveRecord::Migration[6.0]
|
||||
def up
|
||||
DB.exec <<~SQL
|
||||
UPDATE topic_timers
|
||||
SET duration = 0
|
||||
WHERE duration IS NULL AND (execute_at IS NULL OR created_at IS NULL)
|
||||
SQL
|
||||
|
||||
DB.exec <<~SQL
|
||||
UPDATE topic_timers
|
||||
SET duration = EXTRACT(EPOCH FROM execute_at - created_at) / 3600
|
||||
WHERE duration IS NULL AND execute_at IS NOT NULL AND created_at IS NOT NULL
|
||||
SQL
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user