mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 07:13:43 +08:00
21 lines
494 B
Ruby
21 lines
494 B
Ruby
# 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
|