rails3 bigint primary key

前端 未结 6 1570
小鲜肉
小鲜肉 2020-12-11 03:53

I would like to create a bigint (or string or whatever that is not int) typed primary key field under Rails 3.

I have a given

6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-11 04:16

    I had the same problem. I think the easiest way for a table

    accounts 
    id bigint primary key 
    name char 

    is

    create_table :accounts do |t|
    t.string :name
    end
    change_column :accounts, :id , "bigint NOT NULL AUTO_INCREMENT"

提交回复
热议问题