# Table creation using migration

**URL:** <https://www.ruby-forum.com/t/table-creation-using-migration/89411>\
**Category:** Rails\
**Created:** [March 20, 2007, 8:27am UTC](https://www.ruby-forum.com/t/table-creation-using-migration/89411 "2007-03-20T08:27:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![moo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c4cdca/32.png) [@moo](https://www.ruby-forum.com/u/moo)\
**Post date:** [March 20, 2007, 8:27am UTC](https://www.ruby-forum.com/t/table-creation-using-migration/89411/1 "2007-03-20T08:27:31Z")

</div>

Hi…

to create a table with relationship to the other table…using the  
migration how does we do that

table1 : id  
field1,  
field2,  
table2 : id  
field\_table1\_id,  
field2,  
field3,

there is one to many relationship between table1 to table2…

how do we create this using migration…

---

<div class="post-metadata">

**Author:** ![moo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c4cdca/32.png) [@moo](https://www.ruby-forum.com/u/moo)\
**Post date:** [March 20, 2007, 12:47pm UTC](https://www.ruby-forum.com/t/table-creation-using-migration/89411/2 "2007-03-20T12:47:48Z")

</div>

moo wrote:

> there is one to many relationship between table1 to table2…
> 
> how do we create this using migration…

Using the create\_table method, which I am sure you can find the  
instructions for in the API reference.

The database doesn’t care about your one to many relation ship, so don’t  
worry about that when doing the migration. That goes into your model.

–  
Jakob S. - [http://mentalized.net](http://mentalized.net)

---

<div class="post-metadata">

**Author:** ![moo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c4cdca/32.png) [@moo](https://www.ruby-forum.com/u/moo)\
**Post date:** [March 20, 2007, 2:34pm UTC](https://www.ruby-forum.com/t/table-creation-using-migration/89411/3 "2007-03-20T14:34:19Z")

</div>

moo wrote:

> how do we create this using migration…

You do it in your models 🙂
