mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 07:53:49 +08:00
Make removal of topic columns more resilient to deploys
This commit is contained in:
@ -110,6 +110,32 @@ class ApplicationController < ActionController::Base
|
||||
end
|
||||
end
|
||||
|
||||
def self.last_ar_cache_reset
|
||||
@last_ar_cache_reset
|
||||
end
|
||||
|
||||
def self.last_ar_cache_reset=(val)
|
||||
@last_ar_cache_reset
|
||||
end
|
||||
|
||||
rescue_from ActiveRecord::StatementInvalid do |e|
|
||||
|
||||
last_cache_reset = ApplicationController.last_ar_cache_reset
|
||||
|
||||
if e.message =~ /UndefinedColumn/ && (last_cache_reset.nil? || last_cache_reset < 30.seconds.ago)
|
||||
Rails.logger.warn "Clear Active Record cache cause schema appears to have changed!"
|
||||
|
||||
ApplicationController.last_ar_cache_reset = Time.zone.now
|
||||
|
||||
ActiveRecord::Base.connection.query_cache.clear
|
||||
(ActiveRecord::Base.connection.tables - %w[schema_migrations]).each do |table|
|
||||
table.classify.constantize.reset_column_information rescue nil
|
||||
end
|
||||
end
|
||||
|
||||
raise e
|
||||
end
|
||||
|
||||
class PluginDisabled < StandardError; end
|
||||
|
||||
# Handles requests for giant IDs that throw pg exceptions
|
||||
|
Reference in New Issue
Block a user