2015-07-21 40 views
0

我試圖讓我的Rails應用程序連接到PostgreSQL數據庫。爲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,並安裝在正確的分貝,現在遷移運行成功

+0

添加您的修復程序作爲答案並簽名爲正確 – coorasse

回答

0

我安裝了擴展名在錯誤的分貝。通過pgAdmin的去了,安裝在正確的數據庫,現在遷移運行成功

安裝的擴展在查詢字段運行以下命令:

CREATE extension IF NOT EXISTS pgcrypto SCHEMA pg_catalog;

相關問題