Skip to content

Commit

Permalink
Fix pending migration check for Rails 7.2
Browse files Browse the repository at this point in the history
Rails 7.2 removed migration_context from ActiveRecord::Base.connection
  • Loading branch information
tvdeyen committed Sep 12, 2024
1 parent 69088e2 commit 594eef5
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions core/lib/spree/testing_support/dummy_app/migrations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,12 @@ module DummyApp
module Migrations
extend self

# Ensure database exists
def database_exists?
ActiveRecord::Base.connection
rescue ActiveRecord::NoDatabaseError
false
else
true
end

def needs_migration?
return true if !database_exists?

ActiveRecord::Base.connection.migration_context.needs_migration?
ActiveRecord::Migration.check_all_pending!
rescue ActiveRecord::PendingMigrationError, ActiveRecord::NoDatabaseError
true
else
false
end

def auto_migrate
Expand Down

0 comments on commit 594eef5

Please sign in to comment.