Skip to content

Commit

Permalink
Add multi database support for pending migration error
Browse files Browse the repository at this point in the history
Add PendingMigrationError actionable error multi database support
by directly invoking the db:migrate rake task in the action.
  • Loading branch information
beauraF committed May 29, 2024
1 parent f3b154d commit caa7aae
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions activerecord/lib/active_record/migration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,8 @@ class PendingMigrationError < MigrationError # :nodoc:
include ActiveSupport::ActionableError

action "Run pending migrations" do
ActiveRecord::Tasks::DatabaseTasks.migrate

if ActiveRecord.dump_schema_after_migration
connection = ActiveRecord::Tasks::DatabaseTasks.migration_connection
ActiveRecord::Tasks::DatabaseTasks.dump_schema(connection.pool.db_config)
end
Rails.application.load_tasks
Rake::Task["db:migrate"].invoke
end

def initialize(message = nil, pending_migrations: nil)
Expand Down

0 comments on commit caa7aae

Please sign in to comment.