Skip to content

Use filename when printing pending migrations #46461

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

Conversation

adrianna-chang-shopify
Copy link
Contributor

Filename provides the path, whereas basename does not. It makes sense to show the full filename, since migrations can be stored across directories in multi-db apps.

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.
  • CI is passing.

Filename provides the path, whereas basename does not. It makes
sense to show the full filename, since migrations can be stored across
directories in multi-db apps.
@eileencodes eileencodes merged commit dcc75f9 into rails:main Nov 10, 2022
@swaathi
Copy link
Contributor

swaathi commented Nov 22, 2022

This change doesn't show pending migrations across databases though since ActiveRecord::Base.connection.migration_context.open.pending_migrations only counts the pending migrations of the primary database.

@eileencodes
Copy link
Member

@swaathi - that's only the case for applications calling check_pending! directly. Internally in Rails we loop through the configs to find the pending migrations and pass those to the pending migrations error. See #46097, #46268, and #46399.

So this change is correct. Now db/animals_migrate/123_some_migration.rb. will be output in the list instead of 123_some_migration.rb.

@eileencodes
Copy link
Member

I plan to deprecate check_pending! in favor of calling a method that loops through all the configs, but since it's public I couldn't change it in the previous PRs.

@adrianna-chang-shopify adrianna-chang-shopify deleted the ac-use-filename-pending-migrations branch November 22, 2022 14:34
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.

3 participants