开发者

How to rename fields and make them not nulls

开发者 https://www.devze.com 2023-01-20 04:15 出处:网络
My current schema looks like: create_table "users", :force => true do |t| t.string"username"

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 rails generate, and then have to tweak it manually? How so?


It can help if you specify the Rails version number.

Before 3.0, it is:

Rails: How can I rename a database column in a Ruby on Rails migration?

If it is 3.0 or later, then you can look at the Migration documentation, such as rails generate instead of script/generate.

0

精彩评论

暂无评论...
验证码 换一张
取 消