Create a new table
suggest changeTo create a new users table with the columns name and salary, run the command:
rails generate migration CreateUsers name:string salary:decimal
This will generate the following migration:
class CreateUsers < ActiveRecord::Migration[5.0]
def change
create_table :users do |t|
t.string :name
t.decimal :salary
end
end
end
When the migration name has the form CreateXXX, followed by columns and types, the generator creates the table XXX with those columns. XXX is pluralized the usual Rails way: CreateUsers creates users.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents