Chris
Chris

Reputation: 12181

Rails 3.2 from SQLite locally to Postgres on Heroku

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?

Upvotes: 2

Views: 1880

Answers (1)

John Beynon
John Beynon

Reputation: 37507

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.

Upvotes: 4

Related Questions