Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate check_pending! in favor of check_all_pending! #48134

Merged
merged 1 commit into from May 5, 2023

Conversation

eileencodes
Copy link
Member

check_pending! takes a connection that defaults to Base.connection (or migration_connection but right now that's always Base.connection). This means that we aren't able to loop through all the configs for an environment because this is a public API that accepts a single connection. To fix this I've deprecated check_pending! in favor of check_all_pending! which will loop through the configs and check for pending migrations on all the connections.

Example results:

Migrations are pending. To resolve this issue, run:

        bin/rails db:migrate

You have 3 pending migrations:

db/migrate/20221213152217_create_posts.rb
db/migrate/20230503150812_add_active_column_to_posts.rb
db/secondary_migrate/20230503173111_create_dogs.rb

Before this change, only migrations in db/migrate or db/secondary_migrate would be output by ActiveRecord::Migration.check_pending!. I chose not to accept a connection or db_config argument for this new method because it's not super useful. It's more useful to know all pending migrations. If it becomes problematic, we can reimplement the connection option on this method (or reintroduce check_pending!.

`check_pending!` takes a connection that defaults to `Base.connection`
(or migration_connection but right now that's always Base.connection).
This means that we aren't able to loop through all the configs for an
environment because this is a public API that accepts a single
connection. To fix this I've deprecated `check_pending!` in favor of
`check_all_pending!` which will loop through the configs and check for
pending migrations on all the connections.

Example results:

```
Migrations are pending. To resolve this issue, run:

        bin/rails db:migrate

You have 3 pending migrations:

db/migrate/20221213152217_create_posts.rb
db/migrate/20230503150812_add_active_column_to_posts.rb
db/secondary_migrate/20230503173111_create_dogs.rb
```

Before this change, only migrations in `db/migrate` or
`db/secondary_migrate` would be output by `ActiveRecord::Migration.check_pending!`.
I chose not to accept a connection or db_config argument for this new
method because it's not super useful. It's more useful to know all
pending migrations. If it becomes problematic, we can reimplement the
connection option on this method (or reintroduce `check_pending!`.
@eileencodes eileencodes merged commit 7b9497a into rails:main May 5, 2023
9 checks passed
@eileencodes eileencodes deleted the deprecate-check_pending branch May 5, 2023 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant