I have Ruby (2) on Rails (4) app deployed on OpenShift Enterprise running a Postgres database. After initial deployment the app worked perfectly, information was persisted in the database, routing was working, all the tests were passing - everything was good.
Then I deployed some new changes with git push openshift master. When I went back to the app it was still running, but all the database content (including table structure) was gone.
The output from the push was clean. I didn't write any hooks, or have any funky cron jobs running. I could repeat the process, rebuilding the database, and watch it get blown away on every deployment. This problem was not occurring in my local instance.
tl;dr: Make sure you have a
.openshiftdirectory at your project's root, use this as an example: https://github.com/openshift/rails4-exampleHere's what was going on.
When I created the Rails app I didn't know where I would end up deploying it. Consequently I didn't start with an OpenShift Rails skeleton app or by using
rhc app create ruby-X.X.X -a railsX.When I was told to deploy on open shift I just configured
rhcand set up an openshiftgit remote.This meant there was no
.openshiftdirectory in my project's root. Once I cloned https://github.com/openshift/rails4-example and moved that project's.openshiftdirectory into my project root I was able to deploy without losing my database.