FIX: Rails 6 multisite migrations and plugin migrations

Prior to this change plugin migrations were not working and multisite
migrations not working.

Rails internals changed so we need to account for it.

Specifically semantics of `db:migrate` in rails changed so it is sort of
a "multisite:migrate".
This commit is contained in:
Sam Saffron 2019-09-13 09:17:54 +10:00
parent aa511c5b59
commit 025d4ee91f
2 changed files with 9 additions and 1 deletions

View File

@ -516,7 +516,7 @@ class Plugin::Instance
Rake.add_rakelib(File.dirname(path) + "/lib/tasks")
# Automatically include migrations
migration_paths = Rails.configuration.paths["db/migrate"]
migration_paths = ActiveRecord::Migrator.migrations_paths
migration_paths << File.dirname(path) + "/db/migrate"
unless Discourse.skip_post_deployment_migrations?

View File

@ -48,8 +48,16 @@ task 'db:drop' => [:load_config] do |_, args|
end
end
begin
Rake::Task["db:migrate"].clear
end
# we need to run seed_fu every time we run rake db:migrate
task 'db:migrate' => ['environment', 'set_locale'] do |_, args|
ActiveRecord::Tasks::DatabaseTasks.migrate
Rake::Task['db:_dump'].invoke
SeedFu.seed(DiscoursePluginRegistry.seed_paths)
unless Discourse.skip_post_deployment_migrations?