FIX: Avoid rescuing error in login hint initializer.

On the first migration, trying to access the users table will throw an
error in PostgreSQL's log which has been confusing since users will
report it to us when rebuild fails.
This commit is contained in:
Guo Xiang Tan 2019-01-17 17:22:15 +08:00
parent 1a39f6fd5d
commit 6edf285c89
1 changed files with 5 additions and 4 deletions

View File

@ -1,5 +1,8 @@
# Some sanity checking so we don't count on an unindexed column on boot
if User.limit(20).count < 20 && User.where(admin: true).human_users.count == 0
if ActiveRecord::Base.connection.table_exists?(:users) &&
User.limit(20).count < 20 &&
User.where(admin: true).human_users.count == 0
notice =
if GlobalSetting.developer_emails.blank?
"Congratulations, you installed Discourse! Unfortunately, no administrator emails were defined during setup, so finalizing the configuration <a href='https://meta.discourse.org/t/create-admin-account-from-console/17274'>may be difficult</a>."
@ -17,6 +20,4 @@ if User.limit(20).count < 20 && User.where(admin: true).human_users.count == 0
SiteSetting.global_notice = notice
SiteSetting.has_login_hint = true
end
# we may be booting with no User table eg: first migration, just skip
end rescue nil
end