Ruby on rails 运行rake迁移时遇到postgres错误
我在运行以postgres为后端的rails应用程序时遇到以下uuid错误。有人能帮我解决哪些依赖关系是必需的吗Ruby on rails 运行rake迁移时遇到postgres错误,ruby-on-rails,ruby,database,postgresql,rake,Ruby On Rails,Ruby,Database,Postgresql,Rake,我在运行以postgres为后端的rails应用程序时遇到以下uuid错误。有人能帮我解决哪些依赖关系是必需的吗 [root@localhost webapp]# rake db:migrate (in /root/mysite/webapp) == CreateContributors: migrating ============================================= -- create_table(:contributors, {:i
[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
uuid\u generate\u v1()
函数是的一部分,您必须先将其安装到PostgreSQL中,然后才能使用它。在PostgreSQLcontrib
目录中应该有一个名为uuid ossp.sql
的文件。您可以通过以下方式安装软件包:
$ psql -d your_database < /the/path/to/uuid-ossp.sql
$psql-d您的_数据库
您可能希望以数据库超级用户的身份运行该文件。感谢它现在起作用了,实际上路径是一个问题,它在pgsql/contrib中,我正在postgres Folder中查找该文件在ubuntu上的目录似乎是:/usr/share/postgresql/[postgres version]/extension