rails-migrationsruby-1.8.7

adding a new table using rails migration..?


I want to add new table using rails migration:

**table_name** users_location_track
**columns** id (primary key, auto increment serial),
            user_id (reference to users), location_info (string), 
            creation_time(time-stamp)

please suggest procedure and code I am new to rails?


Solution

  • In Rails You need to write a command like below:

     rails generate migration CreateUserLocationTrack user_id:integer location_info:string 
    

    you don't need creation_time as created_at is created by default.

    For more information, please follow rails guide.