mirror of
https://github.com/discourse/discourse.git
synced 2025-04-09 08:20:54 +08:00
DEV: Refactor seed data filter
Added a small helper class to for seed data because we need to add the same filter to multisite:migrate as we have in db:migrate. Having this filter in both places means we can get rid of the SKIP_SEED flag.
This commit is contained in:
parent
4efc126635
commit
69803599a9
@ -97,6 +97,18 @@ class StdOutDemux
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class SeedHelper
|
||||||
|
def self.paths
|
||||||
|
DiscoursePluginRegistry.seed_paths
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.filter
|
||||||
|
# Allows a plugin to exclude any specified seed data files from running
|
||||||
|
DiscoursePluginRegistry.seedfu_filter.any? ?
|
||||||
|
/^(?!.*(#{DiscoursePluginRegistry.seedfu_filter.to_a.join("|")})).*$/ : nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
task 'multisite:migrate' => ['db:load_config', 'environment', 'set_locale'] do |_, args|
|
task 'multisite:migrate' => ['db:load_config', 'environment', 'set_locale'] do |_, args|
|
||||||
if ENV["RAILS_ENV"] != "production"
|
if ENV["RAILS_ENV"] != "production"
|
||||||
raise "Multisite migrate is only supported in production"
|
raise "Multisite migrate is only supported in production"
|
||||||
@ -153,14 +165,12 @@ task 'multisite:migrate' => ['db:load_config', 'environment', 'set_locale'] do |
|
|||||||
ActiveRecord::Tasks::DatabaseTasks.migrate
|
ActiveRecord::Tasks::DatabaseTasks.migrate
|
||||||
end
|
end
|
||||||
|
|
||||||
seed_paths = DiscoursePluginRegistry.seed_paths
|
SeedFu.seed(SeedHelper.paths, /001_refresh/)
|
||||||
SeedFu.seed(seed_paths, /001_refresh/)
|
|
||||||
|
|
||||||
execute_concurently(concurrency, exceptions) do |db|
|
execute_concurently(concurrency, exceptions) do |db|
|
||||||
if ENV['SKIP_SEED'] != '1'
|
|
||||||
puts "Seeding #{db}"
|
puts "Seeding #{db}"
|
||||||
SeedFu.seed(seed_paths)
|
SeedFu.seed(SeedHelper.paths, SeedHelper.filter)
|
||||||
end
|
|
||||||
|
|
||||||
if !Discourse.skip_post_deployment_migrations? && ENV['SKIP_OPTIMIZE_ICONS'] != '1'
|
if !Discourse.skip_post_deployment_migrations? && ENV['SKIP_OPTIMIZE_ICONS'] != '1'
|
||||||
SiteIconManager.ensure_optimized!
|
SiteIconManager.ensure_optimized!
|
||||||
@ -203,12 +213,7 @@ task 'db:migrate' => ['load_config', 'environment', 'set_locale'] do |_, args|
|
|||||||
end
|
end
|
||||||
|
|
||||||
SeedFu.quiet = true
|
SeedFu.quiet = true
|
||||||
|
SeedFu.seed(SeedHelper.paths, SeedHelper.filter)
|
||||||
# Allows a plugin to exclude any specified seed data files from running
|
|
||||||
filter = DiscoursePluginRegistry.seedfu_filter.any? ?
|
|
||||||
/^(?!.*(#{DiscoursePluginRegistry.seedfu_filter.to_a.join("|")})).*$/ : nil
|
|
||||||
|
|
||||||
SeedFu.seed(DiscoursePluginRegistry.seed_paths, filter)
|
|
||||||
|
|
||||||
if !Discourse.skip_post_deployment_migrations? && ENV['SKIP_OPTIMIZE_ICONS'] != '1'
|
if !Discourse.skip_post_deployment_migrations? && ENV['SKIP_OPTIMIZE_ICONS'] != '1'
|
||||||
SiteIconManager.ensure_optimized!
|
SiteIconManager.ensure_optimized!
|
||||||
|
Loading…
x
Reference in New Issue
Block a user