Pending migrations now show path instead of filename
source link: https://blog.saeloun.com/2022/11/30/many-passes-all-parameters
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Pending migrations now show path instead of filename
Nov 30, 2022 , by Swaathi Kakarla
1 minute read
When migrations are pending to be executed, 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
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK