Help with the first migration, you want to rename the fields and make them not zeros

My current schema looks like this:

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 "username" and make all the fields non-empty (they can be reset now).

How should I do it?

Create a migration file using the rails generate command and then configure it manually? how it is?

+3
source share
1 answer

it can help if you specify the version number of Rails.

Up to 3.0 it

How to rename a database column when migrating Ruby on Rails?

if it is 3.0 or newer, you can look

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

for example rails generateinsteadscript/generate

+1
source

Source: https://habr.com/ru/post/1770033/


All Articles