【问题标题】:Starting PostgreSQL database for Rails app为 Rails 应用程序启动 PostgreSQL 数据库
【发布时间】: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 并安装在正确的数据库中,现在迁移成功运行

【问题讨论】:

标签: ruby-on-rails database postgresql rake rake-task


【解决方案1】:

我在错误的数据库中安装了扩展。通过 PgAdmin 并安装在正确的数据库中,现在迁移成功运行

通过在查询字段中运行来安装扩展:

CREATE extension IF NOT EXISTS pgcrypto SCHEMA pg_catalog;

【讨论】:

    猜你喜欢
    • 2021-04-26
    • 2011-10-08
    • 2016-04-23
    • 2021-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-05
    相关资源
    最近更新 更多