Rails 3.2从本地SQLite到Heroku上的Postgres [英] Rails 3.2 from SQLite locally to Postgres on Heroku

查看:94
本文介绍了Rails 3.2从本地SQLite到Heroku上的Postgres的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用sqlite在本地开发应用程序,但现在想将其移至Heroku,所以我将从现在开始使用postgres。我不需要保留数据库,因为它到目前为止,我只需要Heroku不尝试安装Sqlite,因为它爆炸如此:

  Gem :: Installer :: ExtensionBuildError:错误:无法构建gem本机扩展。 
/ usr / local / bin / ruby​​ extconf.rb
检查sqlite3.h ...没有
sqlite3.h缺失。试试'port install sqlite3 + universal'
或'yum install sqlite-devel'并检查你的共享库搜索路径(sqlite3共享库所在的
位置)。
*** extconf.rb失败***
由于某些原因无法创建Makefile,可能缺少
必需的库和/或头文件。查看mkmf.log文件以获取更多
的详细信息。您可能需要配置选项。

我改变了我的database.yml文件并切换了'gem'sqlite3 'gem'pg在我的Gemfile中,但是heroku仍然很生气。还有什么需要改变的,所以当我提交我的应用程序时,它不会尝试安装sqlite3?解析方案

你的Gemfile使用gem'pg',那么你需要重新运行 bundle 命令。一旦你这样做了,把你的Gemfile和Gemfile.lock配置成git,然后把应用程序推送到Heroku,它应该可以工作。



如果你不运行Postgres那么当你在本地运行软件包时,你应该在你的Gemfile中将gem'pg'添加到你的生产组中,否则当你尝试编译gem时会遇到问题。您可以安全地将gem'sqlite'移动到您的Gemfile中的开发组以在环境之间使用不同的DB。 但是警告说,在部署到本地时,在本地运行相同的数据库是最安全的。


I've developing an app locally with sqlite but now want to move it to Heroku, so I will use postgres from now on. I don't need to keep the database as it is so far, I just need Heroku to not try to install Sqlite because it blows up like so:

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
       /usr/local/bin/ruby extconf.rb
       checking for sqlite3.h... no
       sqlite3.h is missing. Try 'port install sqlite3 +universal'
       or 'yum install sqlite-devel' and check your shared library search path (the
       location where your sqlite3 shared library is located).
       *** 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.

I have changed my database.yml file and switched 'gem' "sqlite3" to 'gem' "pg" in my Gemfile, but heroku is still mad. What else needs to change so it doesn't try to install sqlite3 when I commit my app?

解决方案

Once you've changed your Gemfile to use gem 'pg' then you need to rerun the bundle command. Once you've done that, commit your Gemfile and Gemfile.lock to git and then push the application to Heroku and it should work.

If you don't run Postgres locally then you should add gem 'pg' to your production group in your Gemfile else when you run bundle locally you'll have issues when it tries to compile the gem. You could safely move gem 'sqlite' to a development group in your Gemfile to use different DBs between environments. But bewarned it's safest to run the same DB locally when as you are deploying to.

这篇关于Rails 3.2从本地SQLite到Heroku上的Postgres的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆