Updating Schema

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

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

Max Power 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

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.

thanks... i was close now i got it :slight_smile: