1.创建迁移
rails generate migration ModifyPeople
2.迁移命令
删除表格
drop_table :time_configs
删除字段
remove_column :people, :person_m_id
删除索引
remove_index :people, name: "index_people_on_person_m_id_and_department_id"
添加表格
create_table :people do |t|
t.string :name, null: false
t.string :age, :gender , :phone, :email
t.string :person_id
t.string :person_m_id, null: false
t.timestamps
end
添加字段
add_column :people, :department_id, :integer
添加索引
add_index :people, [:person_m_id, :department_id]