rails增加列
rails generate migration NAME [field[:type][:index] field[:type][:index]] [options]
bundle exec rake db:migrate
这将产生以下迁移:
class AddDetailsToUsers < ActiveRecord::Migration[5.0]
def change
add_column :users, :name, :string
add_column :users, :salary, :decimal
add_column :users, :email, :string
end
end
在表增加created_at timestamp(6) without time zone NOT NULL, updated_at timestamp(6) without time zone NOT NULL,
def change
create_table :lines_sources do |t|
t.datetime :created_at, null: false
end
end