# Create databases with rake

**URL:** <https://www.ruby-forum.com/t/create-databases-with-rake/59613>\
**Category:** Rails\
**Created:** [May 4, 2006, 5:37pm UTC](https://www.ruby-forum.com/t/create-databases-with-rake/59613 "2006-05-04T17:37:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![eno](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/f1d935/32.png) [@eno](https://www.ruby-forum.com/u/eno)\
**Post date:** [May 4, 2006, 5:37pm UTC](https://www.ruby-forum.com/t/create-databases-with-rake/59613/1 "2006-05-04T17:37:27Z")

</div>

hi,  
is there a way to create the database (say development and or  
production) specified in database.yml with rake?  
thanks,  
Enrico

–  
“The only thing necessary for the triumph of evil  
is for good men to do nothing”  
Edmund Burke

---

<div class="post-metadata">

**Author:** ![eno](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/f1d935/32.png) [@eno](https://www.ruby-forum.com/u/eno)\
**Post date:** [May 4, 2006, 5:43pm UTC](https://www.ruby-forum.com/t/create-databases-with-rake/59613/2 "2006-05-04T17:43:35Z")

</div>

A production database usually is much more than just the create  
statement.  
For testing and development I use sqlite, where no db creation is  
necessary,  
when you first start to use it it gets created automatically.

---

<div class="post-metadata">

**Author:** ![eno](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/f1d935/32.png) [@eno](https://www.ruby-forum.com/u/eno)\
**Post date:** [May 4, 2006, 5:46pm UTC](https://www.ruby-forum.com/t/create-databases-with-rake/59613/3 "2006-05-04T17:46:43Z")

</div>

Have you looked at the rake migrate utilities.

~A

---

<div class="post-metadata">

**Author:** ![eno](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/f1d935/32.png) [@eno](https://www.ruby-forum.com/u/eno)\
**Post date:** [May 4, 2006, 5:59pm UTC](https://www.ruby-forum.com/t/create-databases-with-rake/59613/4 "2006-05-04T17:59:10Z")

</div>

Isn’t migrations assuming the DB is already there?  
I’m aware of the migrating functionality on tables and data, there’s  
an execute method able to execute the query you pass but still…  
isn’t it assuming the DB is alredy in place?  
I know it’s just a matter of typing few words, I was just wondering  
about a rake way to do it.  
thanks

–  
“The only thing necessary for the triumph of evil  
is for good men to do nothing”  
Edmund Burke

---

<div class="post-metadata">

**Author:** ![eno](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/f1d935/32.png) [@eno](https://www.ruby-forum.com/u/eno)\
**Post date:** [May 4, 2006, 7:24pm UTC](https://www.ruby-forum.com/t/create-databases-with-rake/59613/5 "2006-05-04T19:24:30Z")

</div>

you can initially import your schema with:

rake db\_schema\_import

but i’m not sure about the actual creation of DB.

-tak.

---

<div class="post-metadata">

**Author:** ![eno](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/f1d935/32.png) [@eno](https://www.ruby-forum.com/u/eno)\
**Post date:** [May 8, 2006, 9:30pm UTC](https://www.ruby-forum.com/t/create-databases-with-rake/59613/6 "2006-05-08T21:30:22Z")

</div>

Takashi Okamoto a écrit :

> you can initially import your schema with:
> 
> rake db\_schema\_import
> 
> but i’m not sure about the actual creation of DB.
> 
> -tak.

IMHO, db\_schema\_import task does work only for SQLite. For MySQL I  
always have to create “manually” the empty schemas needed (dev, test,  
prod).  
What about other DBMS ? I don’t know, a try costs nothing …

Didier
