简体   繁体   中英

heroku rake db:migrate ERROR “gem install activerecord-mysql-adapter”

im using Rails 3.2.6 trying to run

heroku run rake db:migrate

i get the adaptar ERROR

rake aborted!
Please install the mysql adapter: `gem install activerecord-mysql-adapter` (mysql is not part of the bundle. Add it to Gemfile.)

in my database.yml i have development, production, and test set to:

adapter: mysql2

this is my gem env

➜  my_app git:(master) gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.24
  - RUBY VERSION: 1.9.3 (2012-11-10 patchlevel 327) [x86_64-darwin11.4.2]
  - INSTALLATION DIRECTORY: /Users/jcollyer/.rvm/gems/ruby-1.9.3-p327
  - RUBY EXECUTABLE: /Users/jcollyer/.rvm/rubies/ruby-1.9.3-p327/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/jcollyer/.rvm/gems/ruby-1.9.3-p327/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-11
  - GEM PATHS:
     - /Users/jcollyer/.rvm/gems/ruby-1.9.3-p327
     - /Users/jcollyer/.rvm/gems/ruby-1.9.3-p327@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

i have tried a few things i found googling, no luck. any help appreciated! thanks!

Remember that Heroku uses the config property DATABASE_URL instead of your database.yml file for connecting to your db. Make sure it is set. If you are using the ClearDB add-on, then the value you want should be in the CLEARDB_DATABASE_URL.

heroku config

Copy the value that ClearDB will have set for you in the CLEARDB_DATABASE_URL config variable. Set the DATABASE_URL to the same value

heroku config:set DATABASE_URL=mysql2://bb06ca765fb123:71b6dabc@us-cdbr-east-04.cleardb.com/heroku_703eded6aebc123?reconnect=true

Here's the catch. Most people are using the mysql2 gem, so you typically need to set the DATABASE_URL to mysql2... instead of mysql.

There's no need to abandon mysql and migrate to postgre.

On Heroku, your best option for a database is postgresql, hands down. There are a handful of reasons that boil down to: that's how Heroku was designed to work.

If you're simply using the rails orm you can use the mysql2psql gem in your development environment and change your config files to use postgresql in production.

If you're really married to mysql for whatever reason, you'll need to install a heroku addon to get your app up and running. There are a couple options but here's one: https://addons.heroku.com/cleardb

But really, your best bet is to migrate your app to postgresql, it's worth it.

More info here: https://devcenter.heroku.com/articles/heroku-mysql

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM