1

Trying to use uuid in my new project.

Although I already enabled the extension by

enable_extension 'uuid-ossp'

I am still getting PG::UndefinedFunction: ERROR: function gen_random_uuid() does not exist.

I have been using uuid and postgres in rails 4.2.x without problem. Anyone has clue?

Edmund Lee
  • 2,514
  • 20
  • 29
  • Possible duplicate of [Rails + Postgres migration - why am I receiving the error "PG::UndefinedFunction: ERROR: function gen\_random\_uuid() does not exist"?](https://stackoverflow.com/questions/47064090/rails-postgres-migration-why-am-i-receiving-the-error-pgundefinedfunction) – Kyle Krzeski Apr 03 '18 at 11:18

1 Answers1

4

gen_random_uuid() is not in uuid-ossp but in pgcrypto

https://www.postgresql.org/docs/10/static/uuid-ossp.html https://www.postgresql.org/docs/10/static/pgcrypto.html

So you need enable_extension "pgcrypto"

GorillaApe
  • 3,611
  • 10
  • 63
  • 106