运行 rake 迁移时遇到 postgres 错误
我在运行以 postgres 作为后端的 Rails 应用程序时收到以下 uuid 错误。有人可以帮我解决需要哪种依赖吗?
[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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
uuid_generate_v1()
函数是 uuid 的一部分-ossp package 并且你必须将其安装到 PostgreSQL 中才能使用它。您的 PostgreSQLcontrib
目录中应该有一个名为uuid-ossp.sql
的文件。您可以通过以下方式安装该软件包:您可能希望以数据库超级用户身份运行该软件包。
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 calleduuid-ossp.sql
in your PostgreSQLcontrib
directory. You can install the package with:You'll probably want to run that as the database super user.