My test is failing with “Migrations are pending”. As migrations should be run automatically, this would seem to be a bug.
It seems that the migration failed (still not sure why; it succeeds on my machine on the same database). The CI log does not report the error from the failed migration.
I am having the same issue. Everything builds fine on my environment, but not with Circle CI. And when I try to run
- bundle exec rake db:migrate RAILS_ENV=test I am getting errors that the tables already exist. I noticed it creates the database schema by running - bundle exec rake db:create db:schema:load --trace And it loads the whole schema, so why is it even asking for migrations?
This probably isn’t the right way to fix this but for now I commented out ActiveRecord::Migration.maintain_test_schema! in Rails_Helper for RSpec and it worked. I don’t understand why it’s trying to run the migrations when Circle CI does a rake db:create and loads the schema. There is nothing to migrate when creating a new db from the schema… I’m sure there might be ramifications down the line that I’ll run into but at least rspec is running now.
I found workaround with adding this to my circle.yml file -
database:
override:
- bundle exec rails db:create; bundle exec rails db:migrate; bundle exec rails db:migrate RAILS_ENV=test
This configuration runs successfully in circleci.
machine:
ruby:
version: 2.3.1
dependencies:
pre:
- gem install bundler
post:
- bundle exec rake assets:precompile
database:
override:
- bundle exec rake db:drop
- bundle exec rake db:create RAILS_ENV=test
- bundle exec rake db:migrate RAILS_ENV=test
test:
post:
- bundle exec rake test