2017-08-31 12:06:56 +08:00
|
|
|
class MigrateTosSetting < ActiveRecord::Migration[4.2]
|
2014-09-30 04:59:03 +08:00
|
|
|
def up
|
|
|
|
res = execute("SELECT * FROM site_settings WHERE name = 'tos_accept_required' AND value = 't'")
|
2014-09-30 22:51:01 +08:00
|
|
|
if res.present? && res.cmd_tuples > 0
|
2016-02-03 00:49:57 +08:00
|
|
|
label = nil
|
|
|
|
|
|
|
|
I18n.overrides_disabled do
|
2018-11-08 00:59:42 +08:00
|
|
|
label = I18n.t("terms_of_service.signup_form_message", base_path: "")
|
2016-02-03 00:49:57 +08:00
|
|
|
end
|
|
|
|
|
2014-09-30 04:59:03 +08:00
|
|
|
res = execute("SELECT value FROM site_texts WHERE text_type = 'tos_signup_form_message'")
|
|
|
|
if res.present? && res.cmd_tuples == 1
|
|
|
|
label = res[0]['value']
|
|
|
|
end
|
|
|
|
|
|
|
|
label = PG::Connection.escape_string(label)
|
|
|
|
execute("INSERT INTO user_fields (name, field_type, editable) VALUES ('#{label}', 'confirm', false)")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|