Adding a column to an existing table in a Rails migration

后端 未结 11 1801
借酒劲吻你
借酒劲吻你 2020-11-28 00:34

I have a Users model which needs an :email column (I forgot to add that column during the initial scaffold).

I opened the migration file and added

11条回答
  •  离开以前
    2020-11-28 00:55

    You can also force to table columns in table using force: true, if you table is already exist.

    example:

    ActiveRecord::Schema.define(version: 20080906171750) do
      create_table "authors", force: true do |t|
        t.string   "name"
        t.datetime "created_at"
        t.datetime "updated_at"
      end
    end
    

提交回复
热议问题