mardi 9 août 2016

Duplicate column error on rails4

I been currently having trouble with my schema file it says: " duplicate column name: user_id: ALTER TABLE "posts" ADD "user_id" integer ". I wanted to add user_id to the post table but it wasn't added on. if i drop the migration the schema file will still be the say so my question what do i need to do to get the user_id to the posts table. Also my second question is can you remove a column from the schema.rb


schema.rb

    ActiveRecord::Schema.define(version: 20160810025455) do

  create_table "posts", force: :cascade do |t|
    t.text     "content"
    t.integer  "user_id"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

  add_index "posts", ["user_id"], name: "index_posts_on_user_id"

  create_table "users", force: :cascade do |t|
    t.string   "email",                  default: "", null: false
    t.string   "encrypted_password",     default: "", null: false
    t.string   "reset_password_token"
    t.datetime "reset_password_sent_at"
    t.datetime "remember_created_at"
    t.integer  "sign_in_count",          default: 0,  null: false
    t.datetime "current_sign_in_at"
    t.datetime "last_sign_in_at"
    t.string   "current_sign_in_ip"
    t.string   "last_sign_in_ip"
    t.datetime "created_at",                          null: false
    t.datetime "updated_at",                          null: false
    t.string   "username"
  end

  add_index "users", ["email"], name: "index_users_on_email", unique: true
  add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true

end

Aucun commentaire:

Enregistrer un commentaire