Question

Heroku's decision to force Postgres use is giving me some major grief. After trying for a while to continue using SQLite in dev and Postgres in production/Heroku, I gave up and did as Heroku "strongly recommends", I started using Postgres for development. After multiple postgres install challenges on my Mac, it is finally installed and working with Rails.

Unlike SQLite, the Postres/Rails setup seems to require my database exist in the Postgres hierarchy and not locally in my project directory. That means git cannot handle database migration states in my various code branches. Now I have to manually track what migrations are associated with which branches and do manual rollbacks and sample-data loading every time I change git branches.

Is there a solution to this? Can your Rails 3.1 project's Postgres database easily be put under git version control?

Was it helpful?

Solution

Personally, I just have it migrate from scratch all of the time (though I am not using rails—sinatra and the sequel gem). For rails you could have it do db:schema:load, then run the missing migrations. I also have a rake task that loads dummy data that I do when I need to.

However, you can run postgres from local directories instead of system wide.

You'll first need to stop your daemonized postgres if it's running (on os x there isn't enough shared memory allocated to have two postgres processess running). Then do the following:

  1. initdb data or whatever local dir you want the data to go
  2. postgres -D data & or omit the & and open a new terminal
  3. createdb myapp-development

I'd like to get all of that down to just one step someday.

Some of my colleges like to have an Sysfile, and use foreman -f Sysfile to start up system dependancies separately from their app's Procfile.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top