开发者

Add_Index() Error using Rails ,PostGres and Windows xp

开发者 https://www.devze.com 2023-01-25 10:12 出处:网络
I\'m trying to add an index to my models, but keep开发者_如何学Go getting this error. PG:Error Error:column \"user_id\" does

I'm trying to add an index to my models, but keep开发者_如何学Go getting this error.

PG:Error Error:column "user_id" does not exist :CREATE INDEX "index_users_on_user_id" ON "users" ("user_id")

class CreateUsers < ActiveRecord::Migration
  def self.up
    create_table :users do |t|
      t.references :role
      t.references :carrier
      t.string "first_name"
      t.string "last_name"
      t.string "user_name"
      t.string "hashed_password"
      t.string "user_salt"
      t.string "telephone"

      t.timestamps
    end
    add_index("users", "user_id")
    add_index("users", "role_id")
    add_index("users", "user_name")
  end

  def self.down
    drop_table :users
  end
end


You don't have anywhere the column user_id in the migration. The automagical column that rails creates for you is called 'id'.

0

精彩评论

暂无评论...
验证码 换一张
取 消