rake db:migration not working on travis-ci build

风流意气都作罢 提交于 2019-12-03 02:21:00
Paul Fioravanti

This blog post helped me tremendously when I was trying to get my Rails 3.2 app working with Travis CI, and write a .travis.yml file that actually worked. Here's mine for your reference, so hope it helps:

.travis.yml

language: ruby
rvm:
  - 1.9.2
  - 1.9.3
env:
  - DB=sqlite
  - DB=mysql
  - DB=postgresql
script: 
  - RAILS_ENV=test bundle exec rake db:migrate --trace
  - bundle exec rake db:test:prepare
  - bundle exec rspec spec/
before_script:
  - mysql -e 'create database my_app_test'
  - psql -c 'create database my_app_test' -U postgres
bundler_args: --binstubs=./bundler_stubs

Instead of running rake db:migrate RAILS_ENV=test run rake db:test:prepare instead.

This is because rake db:migrate will run all the migrations against your test database, which could take a very long time if you had a lot of migrations. The db:test:prepare task will not do that, instead it will just set up the test database with the schema from db/schema.rb.

Give that a shot and see if that works.

The solution that fixed the problem for me was running: rake db:schema:load instead of rake db:migrate RAILS_ENV=test

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!