rails3 bigint primary key

前端 未结 6 1556
小鲜肉
小鲜肉 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:15

    Had that myself not long ago and found the answer here: Using Rails, how can I set my primary key to not be an integer-typed column?

    You need to set primary_key: false and then use a custom statement before you execute the migration.

    EDIT 1: You need to check your database docs for the exact query to perform. It is executed as a regular SQL statement and needs to be database specific. The example in the question I referred to is for Postgre SQL. If you are on MySQL you might have to change that.

提交回复
热议问题