mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-07 10:56:41 +08:00
We're removing the automatic_backups_enabled toggle and depending solely on the backup_frequency value. This PR replaces the setting and adds a migration for any forum that has automatic_backups_enabled disabled.
27 lines
694 B
Ruby
27 lines
694 B
Ruby
# frozen_string_literal: true
|
|
|
|
class ClearBackupFrequencyIfDisabled < ActiveRecord::Migration[7.2]
|
|
def up
|
|
execute <<~SQL
|
|
INSERT INTO site_settings (name, data_type, value, created_at, updated_at)
|
|
SELECT 'backup_frequency', 3, NULL, 'NOW()', 'NOW()'
|
|
WHERE EXISTS (
|
|
SELECT 1
|
|
FROM site_settings
|
|
WHERE name = 'automatic_backups_enabled'
|
|
AND VALUE = 'f'
|
|
LIMIT 1
|
|
)
|
|
ON CONFLICT (name) DO UPDATE SET value = NULL, updated_at = 'NOW()';
|
|
SQL
|
|
|
|
execute <<~SQL
|
|
DELETE FROM site_settings
|
|
WHERE name = 'automatic_backups_enabled';
|
|
SQL
|
|
end
|
|
|
|
def down
|
|
raise ActiveRecord::IrreversibleMigration
|
|
end
|
|
end
|