creating tables in ruby-on-rails 3 through migrations?

Posted by fayer on Stack Overflow See other posts from Stack Overflow or by fayer
Published on 2010-06-13T07:40:33Z Indexed on 2010/06/13 7:42 UTC
Read the original article Hit count: 136

Filed under:

im trying to understand the process of creating tables in ruby-on-rails 3.

i have read about migrations. so i am supposed to create tables by editing in the files in:

Database Migrations/migrate/20100611214419_create_posts
Database Migrations/migrate/20100611214419_create_categories

but they were generated by:

rails generate model Post name:string description:text
rails generate model Category name:string description:text

does this mean i have to use "rails generate model" command everytime i want to create a table?

what if i create a migration file but want to add columns. do i create another migration file for adding those or do i edit the existing migration file directly? the guide told me to add a new one, but here is the part i dont understand. why would i add a new one? cause then the new state will be dependent of 2 migration files.

in symfony i just edit a schema.yml file directly, there are no migration files with versioning and so on.

im new to RoR and want to get the picture of creating tables.

thanks

© Stack Overflow or respective owner

Related posts about ruby-on-rails