FIX: Avoid rescuing error in login hint initializer.

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.

diff --git a/config/initializers/006-ensure_login_hint.rb b/config/initializers/006-ensure_login_hint.rb
index 895f451..af583da 100644
--- a/config/initializers/006-ensure_login_hint.rb
+++ b/config/initializers/006-ensure_login_hint.rb
@@ -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

GitHub sha: 6edf285c

This commit has been mentioned on Discourse Meta. There might be relevant details there:

Fix the build.