mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 20:26:35 +08:00
98a17edc90
The migration for the ToS signup field happend in 2014. Everyone who hasn't updated yet needs to live with the English text "Terms of Service". There's no need to keep these unused translations forever.
19 lines
631 B
Ruby
19 lines
631 B
Ruby
# frozen_string_literal: true
|
|
|
|
class MigrateTosSetting < ActiveRecord::Migration[4.2]
|
|
def up
|
|
res = execute("SELECT * FROM site_settings WHERE name = 'tos_accept_required' AND value = 't'")
|
|
if res.present? && res.cmd_tuples > 0
|
|
label = 'Terms of Service'
|
|
|
|
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
|