Forum: Ruby on Rails how to disable auto-increment in primary key.

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Vipin (Guest)
on 2009-05-01 07:47
(Received via mailing list)
How can i disable the auto-increment for a primary key data type.  The
purpose of using primary_key data type is using different name for
primary key. But we still want to use all the properties of "id"
except for auto increment part.


I had my migration as following
#=============MIGRATION
def self.up
    create_table :pk2s , :id=> false do |t|
      t.primary_key :uid
      t.string :name

      t.timestamps
    end
  end


# ========== Model
class Pk2 < ActiveRecord::Base
  set_primary_key "uid"
end


--vipin
Robert W. (Guest)
on 2009-05-02 00:39
Vipin wrote:
> How can i disable the auto-increment for a primary key data type.  The
> purpose of using primary_key data type is using different name for
> primary key. But we still want to use all the properties of "id"
> except for auto increment part.

Given that it looks to me like you want to implement uuid fields in your
application maybe this will help:

http://codesnipers.com/?q=node/143&title=Using-UUI...
This topic is locked and can not be replied to.