FIX: Rails 6 multisite migrations and plugin migrations

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”.

diff --git a/lib/plugin/instance.rb b/lib/plugin/instance.rb
index 96bdcc3..4a3211d 100644
--- a/lib/plugin/instance.rb
+++ b/lib/plugin/instance.rb
@@ -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?
diff --git a/lib/tasks/db.rake b/lib/tasks/db.rake
index afc470f..03bbcee 100644
--- a/lib/tasks/db.rake
+++ b/lib/tasks/db.rake
@@ -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?

GitHub sha: 025d4ee9

This commit has been mentioned on Discourse Meta. There might be relevant details there:

FIX: Use migrations path for post_migrate (#8133)