2
votes

I was able to push up to heroku and now I need to migrate the database but I'm getting the error rake aborted!

I ran the command heroku rake db:migrate and my command line error was

WARNING: `heroku rake` has been deprecated. Please use `heroku run rake` instead.
Running `rake db:migrate` attached to terminal... up, run.6184
rake aborted!
uninitialized constant MiniTest::Rails
/app/vendor/bundle/ruby/2.0.0/gems/minitest-4.7.5/lib/minitest/unit.rb:19:in `const_missing'
/app/Rakefile:9:in `<top (required)>'
(See full trace by running task with --trace)

so then I ran command

Running `rake db:migrate` attached to terminal... up, run.8495
rake aborted!
uninitialized constant MiniTest::Rails
/app/vendor/bundle/ruby/2.0.0/gems/minitest-4.7.5/lib/minitest/unit.rb:19:in `const_missing'
/app/Rakefile:9:in `<top (required)>'
(See full trace by running task with --trace)

here is a copy of my Rakefile

#!/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)
require 'rake/dsl_definition'
require 'rake'

Portfolio::Application.load_tasks

MiniTest::Rails::Testing.default_tasks << "features"

here is also a copy of my Gemfile

 group :development, :test do
      gem "minitest-rails"
      gem 'sqlite3'
    end

    group :production do
      gem 'pg'
      gem 'rails_12factor'
    end




    group :test do
      gem "minitest-rails-capybara"
    end

    # Gems used only for assets and not required
    # in production environments by default.
    group :assets do
      gem 'sass-rails',   '~> 3.2.3'
      gem 'coffee-rails', '~> 3.2.1'

      # See https://github.com/sstephenson/execjs#readme for more supported runtimes
      # gem 'therubyracer', :platforms => :ruby

      gem 'uglifier', '>= 1.0.3'
    end

    gem 'jquery-rails'

    # To use ActiveModel has_secure_password
    # gem 'bcrypt-ruby', '~> 3.0.0'

    # To use Jbuilder templates for JSON
    # gem 'jbuilder'

    # Use unicorn as the app server
    # gem 'unicorn'

    # Deploy with Capistrano
    # gem 'capistrano'

    # To use debugger
    # gem 'debugger'

anyone sure what my my problem is and why I can't migrate for heroku?

3

3 Answers

2
votes

Your gemfile only has minitest in the :test group, which is good, but then your rake file tries to use the MiniTest class. Try this:

if Rails.env == "test"
  MiniTest::Rails::Testing.default_tasks << "features"
end
1
votes

Here's why : uninitialized constant MiniTest::Rails

You've specified minitest-rails only for development and test environments. By default heroku runs apps in production env and you don't have minitest-rails for prod.

and a condition to run the test task only for test:

MiniTest::Rails::Testing.default_tasks << "features" if Rails.env == 'test'

0
votes

jeanaux and rb512 are definitely on the right track, thanks!

Heroku uses the Rakefile, you can't reference the MiniTest:Rails module because that gem is only being included in the test and development groups in Gemfile

What I had to do was check for test and development environments, to get Rake working again.

if (Rails.env == "test" || Rails.env == "development")
  MiniTest::Rails::Testing.default_tasks << "features"
end