# Updating Schema

**URL:** <https://www.ruby-forum.com/t/updating-schema/187156>\
**Category:** Rails\
**Created:** [April 18, 2010, 8:54pm UTC](https://www.ruby-forum.com/t/updating-schema/187156 "2010-04-18T20:54:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![paragadosm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c68b51/32.png) [@paragadosm](https://www.ruby-forum.com/u/paragadosm)\
**Post date:** [April 18, 2010, 8:54pm UTC](https://www.ruby-forum.com/t/updating-schema/187156/1 "2010-04-18T20:54:53Z")

</div>

Hey,  
i was thinking about  
“creating-multiple-associations-with-the-same-table” and found this:

> **[Creating multiple associations with the same table - Space Vatican](https://www.spacevatican.org/2008/5/6/creating-multiple-associations-with-the-same-table/)**
>
> Rails makes setting up your associations dead easy and very concise. There’s a whole bunch of options that can be set however as long as you …

ive done everything as written but how can i tell ruby to update by  
database schema?

player:  
id  
name

challenge:  
P1  
P2

after creating i hav a column called players\_id

then i modified my code as in the tutorial … then i should hav  
player1\_id, player2\_id if im right but i just hav the old database  
schema…

greetz skelle

---

<div class="post-metadata">

**Author:** ![paragadosm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c68b51/32.png) [@paragadosm](https://www.ruby-forum.com/u/paragadosm)\
**Post date:** [April 18, 2010, 9:14pm UTC](https://www.ruby-forum.com/t/updating-schema/187156/2 "2010-04-18T21:14:32Z")

</div>

Max P. wrote:

> Hey,  
> i was thinking about  
> “creating-multiple-associations-with-the-same-table” and found this:  
> [Creating multiple associations with the same table - Space Vatican](http://www.spacevatican.org/2008/5/6/creating-multiple-associations-with-the-same-table)
> 
> ive done everything as written but how can i tell ruby to update by  
> database schema?
> 
> player:  
> id  
> name
> 
> challenge:  
> P1  
> P2
> 
> after creating i hav a column called players\_id
> 
> then i modified my code as in the tutorial … then i should hav  
> player1\_id, player2\_id if im right but i just hav the old database  
> schema…
> 
> greetz skelle

Migrations are your friend grasshopper…

You could try (depends on whether saving the existing data in player\_id  
is useful):

1. creating the two new columns (player1\_id and player2\_id) and drop the  
old column player\_id
2. or rename the players\_id column to player1\_id and create a new  
player2\_id column.

Just remember to undo the work you do in the “up” in the “down” part of  
the migration.

---

<div class="post-metadata">

**Author:** ![paragadosm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c68b51/32.png) [@paragadosm](https://www.ruby-forum.com/u/paragadosm)\
**Post date:** [April 18, 2010, 9:34pm UTC](https://www.ruby-forum.com/t/updating-schema/187156/3 "2010-04-18T21:34:02Z")

</div>

thanks… i was close now i got it 🙂
