Take the 2-minute tour ×

my User Model looks like:

    class CreateUsers < ActiveRecord::Migration
       def self.up
         create_table :users do |t|
         t.string :name
         t.string :email


      def self.down
        drop_table :users

If I wanted add one more :attribute, is it best to create another migration file for adding a new column (see another Stackoverflow thread) or can I just manually add t.string :name_of_new_attribute and then rake db:migrate?


share|improve this question
add comment

1 Answer

up vote 11 down vote accepted

The proper way is to create a new migration.

rails generate migration AddDetailsToUser address:string age:integer etc...

and then running rake db:migrate

An alternative to this is to edit the original migration file, reset/destroy the database and re-run all migrations.

share|improve this answer
Thank you very much :) –  GirlCanCode2 Apr 16 '12 at 1:24
So when I would like to add more attributes in the future, can I simply edit this migration file? –  GirlCanCode2 Apr 16 '12 at 4:42
You'd be best to create another migration with the new attributes in it –  Norto23 Apr 16 '12 at 4:43
add comment

Your Answer


