From 6edf285c893fdca4584e73a7274febcd586c665b Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Thu, 17 Jan 2019 17:22:15 +0800 Subject: [PATCH] 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. --- config/initializers/006-ensure_login_hint.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/config/initializers/006-ensure_login_hint.rb b/config/initializers/006-ensure_login_hint.rb index 895f451ffe6..af583da87a6 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 may be difficult." @@ -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