1

I want to use UUIDs as my default key in ruby on rails with a postgres db and I would like Postgres to generate the keys. What is the RoR way of doing this?

1 Answer 1

0

This seems to do the trick:

create_table(:deals, :id => false) do |t|
  t.uuid :uuid, :null => false
  t.integer :quantity
  t.timestamps
end

add_index(:deals, :uuid, :unique => true, :name => 'deals_pkey')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.