Skip to content

Commit

Permalink
Remove deprecated ActiveRecord::Migration.check_pending method
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelfranca committed Feb 20, 2024
1 parent e509a0e commit 02f66fe
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 41 deletions.
4 changes: 4 additions & 0 deletions activerecord/CHANGELOG.md
@@ -1,3 +1,7 @@
* Remove deprecated `ActiveRecord::Migration.check_pending` method.

*Rafael Mendonça França*

* Remove deprecated `ActiveRecord::LogSubscriber.runtime` method.

*Rafael Mendonça França*
Expand Down
17 changes: 0 additions & 17 deletions activerecord/lib/active_record/migration.rb
Expand Up @@ -696,23 +696,6 @@ def nearest_delegate # :nodoc:
delegate || superclass.nearest_delegate
end

# Raises ActiveRecord::PendingMigrationError error if any migrations are pending.
#
# This is deprecated in favor of +check_all_pending!+
def check_pending!(connection = ActiveRecord::Tasks::DatabaseTasks.migration_connection)
ActiveRecord.deprecator.warn(<<-MSG.squish)
The `check_pending!` method is deprecated in favor of `check_all_pending!`. The
new implementation will loop through all available database configurations and find
pending migrations. The prior implementation did not permit this.
MSG

pending_migrations = connection.migration_context.open.pending_migrations

if pending_migrations.any?
raise ActiveRecord::PendingMigrationError.new(pending_migrations: pending_migrations)
end
end

# Raises ActiveRecord::PendingMigrationError error if any migrations are pending
# for all database configurations in an environment.
def check_all_pending!
Expand Down
24 changes: 0 additions & 24 deletions activerecord/test/cases/migration/pending_migrations_test.rb
Expand Up @@ -44,11 +44,6 @@ def test_errors_if_pending
assert_pending_migrations("01_create_foo.rb")
end

def test_errors_if_pending_with_deprecated_method
create_migration "01", "create_foo"
assert_deprecated_check_pending("01_create_foo.rb")
end

def test_checks_if_supported
run_migrations
assert_no_pending_migrations
Expand Down Expand Up @@ -92,25 +87,6 @@ def test_with_stdlib_logger
end

private
def assert_deprecated_check_pending(*expected_migrations)
2.times do
assert_raises ActiveRecord::PendingMigrationError do
assert_deprecated(ActiveRecord.deprecator) do
ActiveRecord::Migration.check_pending!
end
end

error = assert_raises ActiveRecord::PendingMigrationError do
CheckPending.new(proc { flunk }).call({})
end

assert_includes error.message, "Migrations are pending."
expected_migrations.each do |migration|
assert_includes error.message, migration
end
end
end

def assert_pending_migrations(*expected_migrations)
2.times do
assert_raises ActiveRecord::PendingMigrationError do
Expand Down
2 changes: 2 additions & 0 deletions guides/source/7_2_release_notes.md
Expand Up @@ -129,6 +129,8 @@ Please refer to the [Changelog][active-record] for detailed changes.

* Remove deprecated `ActiveRecord::LogSubscriber.reset_runtime` method.

* Remove deprecated `ActiveRecord::Migration.check_pending` method.

### Deprecations

### Notable changes
Expand Down

0 comments on commit 02f66fe

Please sign in to comment.