You can also do following with pg: class FirstSetOfTables < ActiveRecord::Migration[5.1] enable_extension 'pgcrypto' unless extensions.include?('pgcrypto') create_table :tokens, id: :uuid do |t| t.integer :action, null: false, default: 1 t.integer :status, null: false, default: 1 t.datetime :expires_at t.datetime :confirmed_at t.timestamps null: false end end
On Monday, July 10, 2017 at 9:56:56 AM UTC+5:30, johnpea...@gmail.com wrote: > > Hi, I was reading the docs for primary key > <http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/PostgreSQL/ColumnMethods.html#method-i-primary_key> > > on postgresql and I saw that there was a way to add a custom stored > procedure that returns a UUID. There is a test case as well that uses a > custom uuid generator > https://github.com/rails/rails/blob/650ea5e5cf50d8a7242499463cf1762922d330a8/activerecord/test/cases/adapters/postgresql/uuid_test.rb#L193 > > but I wasn't sure how to to implement this myself. > > Like in the test case where do I place 'my_uuid_generator()' and how to > implement it in my rails application? > > Thanks. > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/24a91b19-01d5-4c97-bab3-a9c031e557a1%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.