discourse/db/fixtures/009_users.rb
Sam 3829c78526 PERF: shift most user options out of the user table
As it stands we load up user records quite frequently on the topic pages,
this in turn pulls all the columns for the users being selected, just to
discard them after they are loaded

New structure keeps all options in a discrete table, this is better organised
and allows us to easily add more column without worrying about bloating the
user table
2016-02-17 18:08:25 +11:00

55 lines
1.2 KiB
Ruby

# kind of odd, but we need it, we also need to nuke usage of User from inside migrations
# very poor form
user = User.find_by("id <> -1 and username_lower = 'system'")
if user
user.username = UserNameSuggester.suggest("system")
user.save
end
User.seed do |u|
u.id = -1
u.name = "system"
u.username = "system"
u.username_lower = "system"
u.email = "no_email"
u.password = SecureRandom.hex
u.active = true
u.admin = true
u.moderator = true
u.approved = true
u.trust_level = TrustLevel[4]
end
UserOption.where(user_id: -1).update_all(
email_private_messages: false,
email_direct: false
)
Group.user_trust_level_change!(-1, TrustLevel[4])
# User for the smoke tests
if ENV["SMOKE"] == "1"
smoke_user = User.seed do |u|
u.id = 0
u.name = "smoke_user"
u.username = "smoke_user"
u.username_lower = "smoke_user"
u.email = "smoke_user@discourse.org"
u.password = "P4ssw0rd"
u.email_direct = false
u.email_digests = false
u.email_private_messages = false
u.active = true
u.approved = true
u.approved_at = Time.now
u.trust_level = TrustLevel[3]
end.first
EmailToken.seed do |et|
et.id = 1
et.user_id = smoke_user.id
et.email = smoke_user.email
et.confirmed = true
end
end