Fix failure in rake db:migrate on fresh install (#3443).

Create the DanbooruBot account in db/seeds.rb instead of in an
initializer. Move the old db/seeds.rb to db/populate.rb.

Fixes a bug introduced in e2eb45a. Creating DanbooruBot in an
initializer was wrong because in a fresh install the users table doesn't
exist yet. This caused `rake db:migrate` to fail.
This commit is contained in:
evazion
2017-12-21 11:56:12 -06:00
parent b48d5e59ad
commit fcec99405c
5 changed files with 230 additions and 227 deletions

View File

@@ -36,9 +36,10 @@ module Danbooru
"webmaster@#{server_host}"
end
# System actions, such as sending automated dmails, will be performed with this account.
# This account will be created automatically if it doesn't exist. It will
# be promoted to Moderator if it isn't already a Moderator.
# System actions, such as sending automated dmails, will be performed with
# this account. This account must have Moderator privileges.
#
# Run `rake db:seed` to create this account if it doesn't already exist in your install.
def system_user
"DanbooruBot"
end

View File

@@ -1,10 +0,0 @@
require "securerandom"
system = User.find_or_create_by!(name: Danbooru.config.system_user) do |user|
user.password = SecureRandom.base64(32)
end
unless system.is_moderator?
system.level = User::Levels::MODERATOR
system.save
end