2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-31 00:06:56 -04:00
|
|
|
class MigrateTosSetting < ActiveRecord::Migration[4.2]
|
2014-09-29 16:59:03 -04:00
|
|
|
def up
|
|
|
|
res = execute("SELECT * FROM site_settings WHERE name = 'tos_accept_required' AND value = 't'")
|
2014-09-30 10:51:01 -04:00
|
|
|
if res.present? && res.cmd_tuples > 0
|
2019-05-22 10:13:30 -04:00
|
|
|
label = "Terms of Service"
|
2016-02-02 11:49:57 -05:00
|
|
|
|
2014-09-29 16:59:03 -04:00
|
|
|
res = execute("SELECT value FROM site_texts WHERE text_type = 'tos_signup_form_message'")
|
|
|
|
label = res[0]["value"] if res.present? && res.cmd_tuples == 1
|
|
|
|
|
|
|
|
label = PG::Connection.escape_string(label)
|
|
|
|
execute(
|
|
|
|
"INSERT INTO user_fields (name, field_type, editable) VALUES ('#{label}', 'confirm', false)",
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|