views:

29

answers:

1

My current schema looks like:

create_table "users", :force => true do |t|
    t.string   "username"
    t.string   "firstname"
    t.string   "lastname"
    t.datetime "loggedin_at"
    t.datetime "created_at"
    t.datetime "updated_at"
    t.integer  "user_status"
  end

I want to rename "username" to "user_name", and make all the fields not null (they are currently nullable).

How would I do this?

Do I create a migration file using the rails generate command, and then have to tweak it manually? how so?

+1  A: 

it can help if you specify the Rails version number.

Before 3.0, it is

http://stackoverflow.com/questions/1992019/how-to-rename-a-database-column-in-rails-using-migration

if it is 3.0 or later, then you can look at

http://guides.rubyonrails.org/migrations.html

such as rails generate instead of script/generate

動靜能量