How to turn off auto_increment in Rails Active Record

后端 未结 7 1685
日久生厌
日久生厌 2020-12-10 13:00

Is it possible to create primary key without auto_increment flag in ActiveRecord?

I can\'t do

create table :blah, :id          


        
相关标签:
7条回答
  • 2020-12-10 13:46

    Try this?

    create_table(:table_name, :id => false) do |t|
      t.integer :id, :options => 'PRIMARY KEY'
    end
    
    0 讨论(0)
提交回复
热议问题