mirror of
https://github.com/discourse/discourse.git
synced 2024-12-01 07:13:38 +08:00
ac70c48be4
After restoring a backup it takes up to 48 hours for uploads stored on S3 to appear in the S3 inventory. This change prevents alerts about missing uploads by preventing the EnsureS3UploadsExistence job from running in the first 48 hours after a restore. During the restore it deletes the count of missing uploads from the PluginStore, so that an alert isn't triggered by an old number.
29 lines
693 B
Ruby
29 lines
693 B
Ruby
# frozen_string_literal: true
|
|
|
|
class BackupMetadata < ActiveRecord::Base
|
|
LAST_RESTORE_DATE = "last_restore_date"
|
|
|
|
def self.value_for(name)
|
|
where(name: name).pluck_first(:value).presence
|
|
end
|
|
|
|
def self.last_restore_date
|
|
value = value_for(LAST_RESTORE_DATE)
|
|
value.present? ? Time.zone.parse(value) : nil
|
|
end
|
|
|
|
def self.update_last_restore_date(time = Time.zone.now)
|
|
BackupMetadata.where(name: LAST_RESTORE_DATE).delete_all
|
|
BackupMetadata.create!(name: LAST_RESTORE_DATE, value: time.iso8601)
|
|
end
|
|
end
|
|
|
|
# == Schema Information
|
|
#
|
|
# Table name: backup_metadata
|
|
#
|
|
# id :bigint not null, primary key
|
|
# name :string not null
|
|
# value :string
|
|
#
|