0

I am getting the following uuid error while running a rails app with postgres as backend. Can someone help me out with which dependency is needed.

 [root@localhost webapp]# rake db:migrate
    (in /root/mysite/webapp)
    ==  CreateContributors: migrating =============================================
    -- create_table(:contributors, {:id=>false})
       -> 0.0121s
    -- execute("alter table contributors add primary key (id)")
    NOTICE:  ALTER TABLE / ADD PRIMARY KEY will create implicit index "contributors_pkey" for table "contributors"
       -> 0.0797s
    -- execute("alter table contributors alter column id set default uuid_generate_v1()::varchar")
    rake aborted!
    An error has occurred, this and all later migrations canceled:

    PGError: ERROR:  function uuid_generate_v1() does not exist
    HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
    : alter table contributors alter column id set default uuid_generate_v1()::varchar

1 Answer 1

1

The uuid_generate_v1() function is part of the uuid-ossp package and you have to install that into PostgreSQL before you can use it. You should have a file called uuid-ossp.sql in your PostgreSQL contrib directory. You can install the package with:

$ psql -d your_database < /the/path/to/uuid-ossp.sql

You'll probably want to run that as the database super user.

2
  • thanks it worked now actually path was a problem it was in pgsql/contrib and i was looking in postgres folder Commented Feb 20, 2012 at 7:17
  • The directory on ubuntu for this file seems to be: /usr/share/postgresql/[postgres-version]/extension Commented Oct 3, 2013 at 0:02

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.