FIX: Make initializer work on first db:migrate

FIX: Make initializer work on first db:migrate

Follow-up to 94607a2f

diff --git a/config/initializers/100-push-notifications.rb b/config/initializers/100-push-notifications.rb
index 3375823..6b16a07 100644
--- a/config/initializers/100-push-notifications.rb
+++ b/config/initializers/100-push-notifications.rb
@@ -21,7 +21,9 @@ if generate_vapid_key?
   SiteSetting.vapid_public_key_bytes = Base64.urlsafe_decode64(SiteSetting.vapid_public_key).bytes.join("|")
   SiteSetting.vapid_base_url = Discourse.base_url
 
-  PushSubscription.delete_all
+  if ActiveRecord::Base.connection.table_exists?(:push_subscriptions)
+    PushSubscription.delete_all
+  end
 end
 
 DiscourseEvent.on(:user_logged_out) do |user|

GitHub sha: 03d28342

1 Like