Is there a way to automatically do a rake db:migrate RAILS_ENV=test
after each rake db:migrate
when in development environment?
I have guard and guard-rspec running, and I am really annoyed about the failing tests, even if it works manually in the browser.
It costs me at least 15 minutes every time I had a pause from development, to figure out that I simply forgot to call rake db:migrate:test
after the change of the database.
Since I am already using guard I thought about adding guard-rake to the project also, but I dont know which file I should watch. When watching development.sqlite3, rake db:migrate RAILS_ENV=test
would be fired every time I do something with my records through the browser, so this is not really what I want.
Can someone help me with my problem?
rake db:migrate makes changes to the existing schema. Its like creating versions of schema. db:migrate will look in db/migrate/ for any ruby files and execute the migrations that aren't run yet starting with the oldest.
You must rollback the migration (for example with bin/rails db:rollback ), edit your migration, and then run bin/rails db:migrate to run the corrected version.
A Rails migration is a tool for changing an application's database schema. Instead of managing SQL scripts, you define database changes in a domain-specific language (DSL). The code is database-independent, so you can easily move your app to a new platform.
Possibly just make a command alias in your .bashrc
file.
~/.bashrc
alias rake_db_migrate='rake db:migrate db:test:prepare'
Terminal
$ rake_db_migrate
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With