Rails: "Migrations are pending

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 -
- bundle exec rails db:create; bundle exec rails db:migrate; bundle exec rails db:migrate RAILS_ENV=test

1 Like

This configuration runs successfully in circleci.

        version: 2.3.1
        - gem install bundler
        - bundle exec rake assets:precompile
        - bundle exec rake db:drop
        - bundle exec rake db:create RAILS_ENV=test
        - bundle exec rake db:migrate RAILS_ENV=test
        - bundle exec rake test