【发布时间】:2015-10-11 08:29:50
【问题描述】:
我正在尝试将我的 Rails 应用程序连接到 PostgreSQL 数据库。
我成功跑了rake db:create
现在当我运行rake db:migrate 时,我收到以下错误...
===============================================================================
HINT:
You might not have the 'pgcrypto' PostgreSQL extension installed.
Install using:
CREATE extension IF NOT EXISTS pgcrypto SCHEMA pg_catalog;
You can also install it in the 'template1' database for future databases.
===============================================================================
rake aborted!
An error has occurred, this and all later migrations canceled:
PG::UndefinedFunction: ERROR: function gen_salt(unknown) does not exist
LINE 3: (SELECT gen_salt('bf') AS salt)
^
我尝试安装 pgcrypto 扩展,但我得到了同样的错误。
我也试过运行rake db:setup,我得到了这个......
============================================================
WARNING: Pulse calls are disabled until the application is restarted.
rake aborted!
No such file or directory @ rb_sysopen - /Users/kweihe/pmpaware-webapp/db/structure.sql
/Users/kweihe/pmpaware-webapp/lib/tasks/db.rake:8:in `initialize'
/Users/kweihe/pmpaware-webapp/lib/tasks/db.rake:8:in `new'
/Users/kweihe/pmpaware-webapp/lib/tasks/db.rake:8:in `block (3 levels) in <top (required)>'
/Users/kweihe/.rvm/gems/ruby-2.1.6/gems/activerecord-3.2.22/lib/active_record/railties/databases.rake:484:in `block (3 levels) in <top (required)>'
/Users/kweihe/.rvm/gems/ruby-2.1.6/bin/ruby_executable_hooks:15:in `eval'
/Users/kweihe/.rvm/gems/ruby-2.1.6/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => db:structure:load => db:structure:pg_crypto_preflight
(See full trace by running task with --trace)
已修复
我在错误的数据库中安装了扩展。通过 PgAdmin 并安装在正确的数据库中,现在迁移成功运行
【问题讨论】:
-
您的
config/database.yml文件是什么样的?例如,您可能还想查看How To Setup Ruby on Rails with Postgres -
将您的修复添加为答案并将其签名为正确
标签: ruby-on-rails database postgresql rake rake-task