mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 15:32:26 +08:00
30990006a9
This reduces chances of errors where consumers of strings mutate inputs and reduces memory usage of the app. Test suite passes now, but there may be some stuff left, so we will run a few sites on a branch prior to merging
39 lines
878 B
Ruby
39 lines
878 B
Ruby
# frozen_string_literal: true
|
|
|
|
class CreateReviewableUsers < ActiveRecord::Migration[5.2]
|
|
def up
|
|
# Create reviewables for approved users
|
|
if DB.query_single("SELECT 1 FROM site_settings WHERE name = 'must_approve_users' AND value = 't'").first
|
|
execute(<<~SQL)
|
|
INSERT INTO reviewables (
|
|
type,
|
|
status,
|
|
created_by_id,
|
|
reviewable_by_moderator,
|
|
target_type,
|
|
target_id,
|
|
created_at,
|
|
updated_at
|
|
)
|
|
SELECT 'ReviewableUser',
|
|
0,
|
|
#{Discourse::SYSTEM_USER_ID},
|
|
true,
|
|
'User',
|
|
id,
|
|
created_at,
|
|
created_at
|
|
FROM users
|
|
WHERE active AND approved = false
|
|
SQL
|
|
end
|
|
end
|
|
|
|
def down
|
|
execute(<<~SQL)
|
|
DELETE FROM reviewables
|
|
WHERE type = 'ReviewableUser'
|
|
SQL
|
|
end
|
|
end
|