2012-02-20 58 views
0

我在運行rails應用程序和postgres作爲後端時出現以下uuid錯誤。有人可以幫我解決哪些依賴需要。在運行rake遷移時遇到postgres錯誤

[[email protected] 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

uuid_generate_v1()功能是uuid-ossp package的一部分,你必須是安裝到PostgreSQL的,然後才能使用它。您應該在PostgreSQL contrib目錄中有一個名爲uuid-ossp.sql的文件。您可以安裝該軟件包:

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

您可能想要將其作爲數據庫超級用戶運行。

+0

感謝現在的工作其實路徑是有人在的pgsql/contrib請一個問題,我一直在尋找在Postgres的文件夾 – 2012-02-20 07:17:10

+0

在Ubuntu這個文件的目錄似乎是: 在/ usr /共享/ PostgreSQL的/ [Postgres的版本]/延期 – MissingHandle 2013-10-03 00:02:59