# Db folder is empty. how to regenerate?

**URL:** <https://www.ruby-forum.com/t/db-folder-is-empty-how-to-regenerate/173683>\
**Category:** Rails\
**Created:** [August 13, 2009, 10:01am UTC](https://www.ruby-forum.com/t/db-folder-is-empty-how-to-regenerate/173683 "2009-08-13T10:01:06Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![railslist](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/65b543/32.png) [@railslist](https://www.ruby-forum.com/u/railslist)\
**Post date:** [August 13, 2009, 10:01am UTC](https://www.ruby-forum.com/t/db-folder-is-empty-how-to-regenerate/173683/1 "2009-08-13T10:01:06Z")

</div>

by mistake i have deleted the contents of the db folder in an rails app.  
how do i recreate those db migration files?

---

<div class="post-metadata">

**Author:** ![railslist](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/65b543/32.png) [@railslist](https://www.ruby-forum.com/u/railslist)\
**Post date:** [August 13, 2009, 10:10am UTC](https://www.ruby-forum.com/t/db-folder-is-empty-how-to-regenerate/173683/2 "2009-08-13T10:10:36Z")

</div>

On Aug 13, 9:01 am, Rails L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> by mistake i have deleted the contents of the db folder in an rails app.  
> how do i recreate those db migration files?

restore them from source control 🙂

if you just need the structure of the database then rake  
db:schema:dump will dump that.

Fred

---

<div class="post-metadata">

**Author:** ![railslist](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/65b543/32.png) [@railslist](https://www.ruby-forum.com/u/railslist)\
**Post date:** [August 13, 2009, 10:13am UTC](https://www.ruby-forum.com/t/db-folder-is-empty-how-to-regenerate/173683/3 "2009-08-13T10:13:37Z")

</div>

Frederick C. wrote:

> On Aug 13, 9:01ï¿½am, Rails L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > by mistake i have deleted the contents of the db folder in an rails app.  
> > how do i recreate those db migration files?
> 
> restore them from source control 🙂
> 
> if you just need the structure of the database then rake  
> db:schema:dump will dump that.
> 
> Fred

Fred, thanks a lot. it has create the schema dump. if I do db:migrate,  
will it create all the tables using my current connection parameters?

---

<div class="post-metadata">

**Author:** ![railslist](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/65b543/32.png) [@railslist](https://www.ruby-forum.com/u/railslist)\
**Post date:** [August 13, 2009, 1:34pm UTC](https://www.ruby-forum.com/t/db-folder-is-empty-how-to-regenerate/173683/4 "2009-08-13T13:34:20Z")

</div>

On Aug 13, 4:13 am, Rails L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > Fred
> 
> Fred, thanks a lot. it has create the schema dump. if I do db:migrate,  
> will it create all the tables using my current connection parameters?

Um… no? If you need to create a db according to the dumped schema  
(on another machine, I presume), you’d use “rake db:schema:dump”.

And you are using source control, right? I hope?

–Matt J.

---

<div class="post-metadata">

**Author:** ![railslist](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/65b543/32.png) [@railslist](https://www.ruby-forum.com/u/railslist)\
**Post date:** [August 13, 2009, 3:43pm UTC](https://www.ruby-forum.com/t/db-folder-is-empty-how-to-regenerate/173683/5 "2009-08-13T15:43:40Z")

</div>

Matt J. wrote:

> Um… no? If you need to create a db according to the dumped schema  
> (on another machine, I presume), you’d use “rake db:schema:dump”.

Matt, I assume you wanted to type:

$ rake db:schema:load

For the OP, more options:

$ rake -T db:schema  
$ rake -T db  
$ rake -T

You were given an awesome advice, use source control. It can improve  
your life quality immensely. BTW, if I would be asked which one, I’d say  
git. YMMV.

---

<div class="post-metadata">

**Author:** ![railslist](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/65b543/32.png) [@railslist](https://www.ruby-forum.com/u/railslist)\
**Post date:** [August 13, 2009, 4:52pm UTC](https://www.ruby-forum.com/t/db-folder-is-empty-how-to-regenerate/173683/6 "2009-08-13T16:52:59Z")

</div>

xy xy wrote:

> Matt J. wrote:
> 
> > Um… no? If you need to create a db according to the dumped schema  
> > (on another machine, I presume), you’d use “rake db:schema:dump”.
> 
> Matt, I assume you wanted to type:
> 
> $ rake db:schema:load
> 
> For the OP, more options:
> 
> $ rake -T db:schema  
> $ rake -T db  
> $ rake -T
> 
> You were given an awesome advice, use source control. It can improve  
> your life quality immensely. BTW, if I would be asked which one, I’d say  
> git. YMMV.

Thanks for all the answers. I am yet to use source control. Although I  
am sure source control is useful, i haven’t found ( or i didn’t try hard  
enough :-)) any simple tutorial for learning to use git.

---

<div class="post-metadata">

**Author:** ![railslist](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/65b543/32.png) [@railslist](https://www.ruby-forum.com/u/railslist)\
**Post date:** [August 13, 2009, 5:06pm UTC](https://www.ruby-forum.com/t/db-folder-is-empty-how-to-regenerate/173683/7 "2009-08-13T17:06:22Z")

</div>

Rails L. wrote:

> Thanks for all the answers. I am yet to use source control. Although I  
> am sure source control is useful, i haven’t found ( or i didn’t try hard  
> enough :-)) any simple tutorial for learning to use git.

Source control isn’t just useful. It saves lives. And RAILS\_ROOT/db/\*  
files. 😉

You can pick your new favourite Git tutorial/book/screencast at  
[http://git-scm.com/documentation](http://git-scm.com/documentation)
