-2

My database.yml

development:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: organic_tomatoes_development
  pool: 5
  username: root
  password: password

test:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: organic_tomatoes_test
  pool: 5
  username: root
  password: password

I deploy my site on heroku. When I run heroku run rake db:migrate it gives an error

ActiveRecord::AdapterNotSpecified: 'production' database is not configured. Available: ["development", "test"]

How can I solve this error?

Haseeb Ahmad
  • 7,914
  • 12
  • 55
  • 133
  • Possible duplicate of [ActiveRecord::AdapterNotSpecified database configuration does not specify adapter](https://stackoverflow.com/questions/23336755/activerecordadapternotspecified-database-configuration-does-not-specify-adapte) – Kick Buttowski Jun 24 '18 at 00:54
  • @KickButtowski i tried that not solution works – Haseeb Ahmad Jun 24 '18 at 01:33

4 Answers4

1

As per the description shared you only have development and test envirinment specified , you need to add production environment settings as well

But apart from.that you need to add ClearDB as an add-on to use mysql db.

Click Reveal Config Vars and copy the CLEARDB_DATABASE_URL value.

mysql://xxxxx@xxxx.cleardb.net/xxxxx?reconnect=true.

Everything after the @ symbol until the / is the DB_HOST

Everything after / until ? is DB_DATABASE

The string after the // until : is the DB_USERNAME

The string between : and @ is the DB_PASSWORD

   development:
     adapter: mysql2
     encoding: utf8
     reconnect: false
     database: organic_tomatoes_development
     pool: 5
     username: root
     password: password

   test:
    adapter: mysql2
    encoding: utf8
    reconnect: false
    database: organic_tomatoes_test
    pool: 5
    username: root
    password: password

   production:
     adapter: mysql2
     encoding: utf8
     username: xxxx
     password: xxxx
    database: ENV["CLEARDB_DATABASE_URL"]
    pool: 5
Rohan
  • 2,681
  • 1
  • 12
  • 18
0

Create a production entry in your database.yml

production::
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: organic_tomatoes_production
  pool: 5
  username: root
  password: password
jordanm
  • 33,009
  • 7
  • 61
  • 76
Doug
  • 14,387
  • 17
  • 74
  • 104
0
production:
    adapter: mysql2
    encoding: utf8
    reconnect: false
    database: organic_tomatoes_production
    pool: 5

Can you try this?

praaveen V R
  • 1,259
  • 1
  • 11
  • 20
0

I was having this issue this morning and the solution is to set RAILS_ENV variable before running the command'

RAILS_ENV=development heroku local
Nafaa Boutefer
  • 2,169
  • 19
  • 26