mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 07:53:49 +08:00
FEATURE: support multisite configuration for search:reindex task
This commit is contained in:
@ -1,6 +1,9 @@
|
|||||||
task "search:reindex" => :environment do
|
task "search:reindex" => :environment do
|
||||||
RailsMultisite::ConnectionManagement.each_connection do |db|
|
ENV['RAILS_DB'] ? reindex_search : reindex_search_all_sites
|
||||||
puts "Reindexing #{db}"
|
end
|
||||||
|
|
||||||
|
def reindex_search(db=RailsMultisite::ConnectionManagement.current_db)
|
||||||
|
puts "Reindexing '#{db}'"
|
||||||
puts ""
|
puts ""
|
||||||
puts "Posts:"
|
puts "Posts:"
|
||||||
Post.exec_sql("select p.id, p.cooked, c.name category, t.title, p.post_number, t.id topic_id from
|
Post.exec_sql("select p.id, p.cooked, c.name category, t.title, p.post_number, t.id topic_id from
|
||||||
@ -43,4 +46,9 @@ task "search:reindex" => :environment do
|
|||||||
|
|
||||||
puts
|
puts
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def reindex_search_all_sites
|
||||||
|
RailsMultisite::ConnectionManagement.each_connection do |db|
|
||||||
|
reindex_search(db)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user