# Rake db:create doesn't create all databases?

**URL:** <https://www.ruby-forum.com/t/rake-db-create-doesnt-create-all-databases/193198>\
**Category:** Rails\
**Created:** [August 12, 2010, 11:53pm UTC](https://www.ruby-forum.com/t/rake-db-create-doesnt-create-all-databases/193198 "2010-08-12T23:53:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fearless\_fool](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/5e9695/32.png) [@fearless\_fool](https://www.ruby-forum.com/u/fearless_fool)\
**Post date:** [August 12, 2010, 11:53pm UTC](https://www.ruby-forum.com/t/rake-db-create-doesnt-create-all-databases/193198/1 "2010-08-12T23:53:49Z")

</div>

I was trying to create a test case in Rails 3.0 RC2 for an entirely  
separate question about connecting to external databases via  
establish\_connection, but ran into a problem with rake db:create.

In short, “rake db:create” only creates two of the four databases listed  
in config/database.yml, and I can’t figure out why. Here’s the  
database.yml file. The only thing out of the ordinary is the :external  
database specification, but notice that its params are identical to the  
others:

========= file: config/database.yml  
development:  
adapter: mysql  
encoding: utf8  
reconnect: false  
database: dbtest\_development  
pool: 5  
username: root  
password: XYZZY  
socket: /tmp/mysql.sock

external:  
adapter: mysql  
encoding: utf8  
reconnect: false  
database: dbtest\_external  
pool: 5  
username: root  
password: XYZZY  
socket: /tmp/mysql.sock

test:  
adapter: mysql  
encoding: utf8  
reconnect: false  
database: dbtest\_test  
pool: 5  
username: root  
password: XYZZY  
socket: /tmp/mysql.sock

production:  
adapter: mysql  
encoding: utf8  
reconnect: false  
database: dbtest\_production  
pool: 5  
username: root  
password: XYZZY  
socket: /tmp/mysql.sock  
========= EOF

But rake db:create only creates the \_development and \_test databases,  
not the \_external nor \_production. Here’s the synopsis. My db BEFORE:

# ========= bash$ mysql -u root -pXYZZY … mysql\> show databases; ±-------------------+ | Database | ±-------------------+ | information\_schema | | mysql | | test | ±-------------------+ 3 rows in set (0.00 sec) mysql\> quit

When I execute ‘rake db:create’, it appears to complete without error:

# ========= bash$ rake db:create --trace rake db:create --trace (in /Users/r/Developer/dbtest) \*\* Invoke db:create (first\_time) \*\* Invoke db:load\_config (first\_time) \*\* Invoke rails\_env (first\_time) \*\* Execute rails\_env \*\* Execute db:load\_config \*\* Execute db:create

… but the resulting database only has the \_development and \_test  
databases, as shown here:

# ========= bash$ mysql -u root -pXYZZY … mysql\> show databases; ±----------------------+ | Database | ±----------------------+ | information\_schema | | dbtest\_development | | dbtest\_test | | mysql | | test | ±----------------------+ 5 rows in set (0.00 sec) mysql\> quit

What’s odd is that I’ve looked at the sources in

usr/lib/ruby/gems/1.9.1/gems/activerecord-3.0.0.rc/lib/active\_record/railties/databases.rake

and I can’t see a reason that either \_external or \_production would be  
skipped, especially without some error message.

Can any of the wizards out there explain this, or suggest a test I run  
to analyze this in more depth?

TIA.

- ff

---

<div class="post-metadata">

**Author:** ![fearless\_fool](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/5e9695/32.png) [@fearless\_fool](https://www.ruby-forum.com/u/fearless_fool)\
**Post date:** [August 13, 2010, 12:01am UTC](https://www.ruby-forum.com/t/rake-db-create-doesnt-create-all-databases/193198/2 "2010-08-13T00:01:30Z")

</div>

crap. nebbermind. i was reading the wrong piece of code; all i really  
needed to do was:

rake db:create:all

and all is happy. pardon the noise (but maybe my experience will help  
someone else in the future).

- ff
