When migrations are pending to be run, Rails shows a warning message to users on the console. This lists the names of the pending migrations. While this is useful in single database applications, in a multi-database application migration file names may not be unique across databases.
First let’s create a dummy migration.
➜ rails g model blog
invoke active_record
create db/migrate/20221111115257_create_blogs.rb
create app/models/blog.rb
invoke test_unit
create test/models/blog_test.rb
create test/fixtures/blogs.yml
We will not run the migration yet.
Before
Now when we try to run the server or a test, Rails will show a warning message.
➜ rails s
rails aborted!
Migrations are pending. To resolve this issue, run:
bin/rails db:migrate RAILS_ENV=test
You have 1 pending migration:
20221111115257_create_blogs.rb
While this information is useful, it does not tell us where this migration file is located.
After
After this PR Rails shows the entire path.
➜ rails s
rails aborted!
Migrations are pending. To resolve this issue, run:
bin/rails db:migrate RAILS_ENV=test
You have 1 pending migration:
db/migrate/20221111115257_create_blogs.rb