【问题标题】:Changing the Database to pg from sql for Heroku将数据库从 Heroku 的 sql 更改为 pg
【发布时间】:2016-05-02 12:08:17
【问题描述】:

我总是使用默认为 sql 数据库语言的 rails new app_name 启动我的新 Rails 应用程序。我想知道三件事:

  1. 有没有办法在创建应用程序时将数据库语言默认为 pg?
  2. 创建应用程序后,如何将其从 sql 更改为 pg?我尝试更改 gem 文件中的数据库语言,但通常会收到此错误:

    $ gem install pg -v '0.18.4'
    
    Building native extensions.  This could take a while...
    ERROR:  Error installing pg:
        ERROR: Failed to build gem native extension.
    
        current directory: /Users/eric.park/.rvm/gems/ruby-2.3.0/gems/pg-0.18.4/ext
    /Users/eric.park/.rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160125-86030-51pvqj.rb extconf.rb
    checking for pg_config... no
    No pg_config... trying anyway. If building fails, please try again with
     --with-pg-config=/path/to/pg_config
    checking for libpq-fe.h... no
    Can't find the 'libpq-fe.h header
    *** extconf.rb failed ***
    Could not create Makefile due to some reason, probably lack of necessary
    libraries and/or headers.  Check the mkmf.log file for more details.  You may
    need configuration options.
    
    Provided configuration options:
        --with-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/Users/eric.park/.rvm/rubies/ruby-2.3.0/bin/$(RUBY_BASE_NAME)
        --with-pg
        --without-pg
        --enable-windows-cross
        --disable-windows-cross
        --with-pg-config
        --without-pg-config
        --with-pg_config
        --without-pg_config
        --with-pg-dir
        --without-pg-dir
        --with-pg-include
        --without-pg-include=${pg-dir}/include
        --with-pg-lib
        --without-pg-lib=${pg-dir}/lib
    
    To see why this extension failed to compile, please check the mkmf.log which can be found here:
    
      /Users/eric.park/.rvm/gems/ruby-2.3.0/extensions/x86_64-darwin-14/2.3.0/pg-0.18.4/mkmf.log
    
    extconf failed, exit code 1
    
    Gem files will remain installed in /Users/eric.park/.rvm/gems/ruby-2.3.0/gems/pg-0.18.4 for inspection.
    Results logged to /Users/eric.park/.rvm/gems/ruby-2.3.0/extensions/x86_64-darwin-14/2.3.0/pg-0.18.4/gem_make.out
    

最后,Heroku 不支持 sql 的地方在哪里?

【问题讨论】:

    标签: ruby-on-rails sql-server heroku


    【解决方案1】:

    首先,您遇到的错误是因为您需要postgresql 开发工具。

    对于 Mac:brew install postgresql
    对于 Ubuntu:sudo apt-get install libpq-dev
    对于 Fedora:sudo yum install postgresql-develsudo dnf install postgresql-devel

    其次,Heroku 当然支持MySQL,但PostgreSQL 是免费的。

    【讨论】:

      猜你喜欢
      • 2016-03-05
      • 1970-01-01
      • 2014-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-21
      • 2019-12-27
      • 2013-03-12
      相关资源
      最近更新 更多