active我正在尝试向我的表添加新列students。
我跑去rails g migration add_active_to_students active:boolean生成这个迁移:
class AddActiveToStudents < ActiveRecord::Migration[5.0]
def change
add_column :students, :active, :boolean, default: true
end
end
Run Code Online (Sandbox Code Playgroud)
但是当我运行时rails db:migrate我收到此错误:
PG::DuplicateColumn:错误:关系“学生”的列“活动”已存在:ALTER TABLE“学生”添加“活动”布尔值默认“t”`
正如您所看到的,实际上没有一active列students:
create_table "students", force: :cascade do |t|
t.integer "club_id"
t.string "email"
t.string "address_line_1"
t.string "address_line_2"
t.string "city"
t.string "state"
t.integer "postcode"
t.string "phone1"
t.string "phone2"
t.string "first_name"
t.string "last_name"
t.date "dob"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "picture"
t.integer "payment_plan_id"
t.string "parent1" …Run Code Online (Sandbox Code Playgroud)