开发者

Auto-incrementing from 0 in Rails migrations

开发者 https://www.devze.com 2022-12-28 19:15 出处:网络
I needed an id field in my ra开发者_C百科ils migration that auto-increments from 0 and not 1.Any idea?

I needed an id field in my ra开发者_C百科ils migration that auto-increments from 0 and not 1.Any idea? Thanks & Cheers !


I found it in mysql Advance option "The initial AUTO_INCREMENT" value for the Table. you can set there but i don't know whether you can set that using Rails Migration or not.


Modify your db/migrate-file:

create_table :table_name, :options => "auto_increment = 0" do |t|
  ...
end
0

精彩评论

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