FIX: DB migration fails if old site setting has empty value (#18296)
This commit is contained in:
parent
eab33af5bf
commit
b3831362a1
|
@ -4,12 +4,12 @@ class RenameDigestAfterDaysToDigestAfterMinutes < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
rename_column :user_options, :digest_after_days, :digest_after_minutes
|
rename_column :user_options, :digest_after_days, :digest_after_minutes
|
||||||
execute "UPDATE user_options SET digest_after_minutes = digest_after_minutes * 1440 WHERE digest_after_minutes IS NOT NULL"
|
execute "UPDATE user_options SET digest_after_minutes = digest_after_minutes * 1440 WHERE digest_after_minutes IS NOT NULL"
|
||||||
execute "UPDATE site_settings SET value = value::integer * 1440 WHERE name = 'default_email_digest_frequency' AND value IS NOT NULL"
|
execute "UPDATE site_settings SET value = value::integer * 1440 WHERE name = 'default_email_digest_frequency' AND value IS NOT NULL AND value <> ''"
|
||||||
end
|
end
|
||||||
|
|
||||||
def down
|
def down
|
||||||
rename_column :user_options, :digest_after_minutes, :digest_after_days
|
rename_column :user_options, :digest_after_minutes, :digest_after_days
|
||||||
execute "UPDATE user_options SET digest_after_days = digest_after_days / 1440 WHERE digest_after_days IS NOT NULL"
|
execute "UPDATE user_options SET digest_after_days = digest_after_days / 1440 WHERE digest_after_days IS NOT NULL"
|
||||||
execute "UPDATE site_settings SET value = value::integer / 1440 WHERE name = 'default_email_digest_frequency' AND value IS NOT NULL"
|
execute "UPDATE site_settings SET value = value::integer / 1440 WHERE name = 'default_email_digest_frequency' AND value IS NOT NULL AND value <> ''"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue