FIX: Migration paths were being forgotten
According to the [Rails Source](https://github.com/rails/rails/blob/master/activerecord/lib/active_record/railties/databases.rake#L20) the `ActiveRecord::Migrator.migrations_paths` are overwritten with the value of `ActiveRecord::Tasks::DatabaseTasks.migrations_paths` every time the config is loaded. This caused a bug for Discourse development where if you ran: `rake db:drop db:create db:migrate` in one line, you would not get our post migrations, as those had a custom value for `migrations_paths`. The fix is to use `ActiveRecord::Tasks::DatabaseTasks.migrations_paths` to set up all our custom paths. Everything seems to work as expected.
This commit is contained in:
parent
5acecfcb91
commit
ce78eff888
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
unless Discourse.skip_post_deployment_migrations?
|
||||
ActiveRecord::Migrator.migrations_paths << Rails.root.join(
|
||||
ActiveRecord::Tasks::DatabaseTasks.migrations_paths << Rails.root.join(
|
||||
Discourse::DB_POST_MIGRATE_PATH
|
||||
).to_s
|
||||
end
|
||||
|
|
|
@ -526,7 +526,7 @@ class Plugin::Instance
|
|||
Rake.add_rakelib(File.dirname(path) + "/lib/tasks")
|
||||
|
||||
# Automatically include migrations
|
||||
migration_paths = ActiveRecord::Migrator.migrations_paths
|
||||
migration_paths = ActiveRecord::Tasks::DatabaseTasks.migrations_paths
|
||||
migration_paths << File.dirname(path) + "/db/migrate"
|
||||
|
||||
unless Discourse.skip_post_deployment_migrations?
|
||||
|
|
|
@ -84,7 +84,7 @@ module TurboTests
|
|||
.configurations["test"]
|
||||
.merge("database" => "discourse_test_1")
|
||||
|
||||
ActiveRecord::Migrator.migrations_paths = ['db/migrate', 'db/post_migrate']
|
||||
ActiveRecord::Tasks::DatabaseTasks.migrations_paths = ['db/migrate', 'db/post_migrate']
|
||||
|
||||
conn = ActiveRecord::Base.establish_connection(config).connection
|
||||
begin
|
||||
|
|
Loading…
Reference in New Issue