2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-06-17 04:15:43 -04:00
|
|
|
class SeedData::Refresher
|
2020-06-22 21:15:29 -04:00
|
|
|
@mutex = Mutex.new
|
|
|
|
|
2020-06-17 04:15:43 -04:00
|
|
|
def self.refresh!
|
|
|
|
return if @refreshed
|
|
|
|
|
2020-06-22 21:15:29 -04:00
|
|
|
@mutex.synchronize do
|
|
|
|
return if @refreshed
|
|
|
|
# Fix any bust caches post initial migration
|
2021-05-20 21:43:47 -04:00
|
|
|
# Not that reset_column_information is not thread safe so we have to be careful
|
2020-06-22 21:15:29 -04:00
|
|
|
# not to run it concurrently within the same process.
|
|
|
|
ActiveRecord::Base.connection.tables.each do |table|
|
2023-01-09 06:59:41 -05:00
|
|
|
begin
|
2020-06-22 21:15:29 -04:00
|
|
|
table.classify.constantize.reset_column_information
|
|
|
|
rescue StandardError
|
|
|
|
nil
|
2023-01-09 06:59:41 -05:00
|
|
|
end
|
2020-06-22 21:15:29 -04:00
|
|
|
end
|
2020-06-17 04:15:43 -04:00
|
|
|
|
2020-06-22 21:15:29 -04:00
|
|
|
@refreshed = true
|
|
|
|
end
|
2020-06-17 04:15:43 -04:00
|
|
|
end
|
2020-06-17 01:23:45 -04:00
|
|
|
end
|
|
|
|
|
2020-06-17 04:15:43 -04:00
|
|
|
SeedData::Refresher.refresh!
|
2019-03-18 16:09:13 -04:00
|
|
|
SiteSetting.refresh!
|