Search code examples
sinatraopenshiftruby-datamapper

DB reset after pushing to openshift


I have a Sinatra project that I'm publishing through Openshift.

Every time I'm pushing the changes to the openshift remote, the datebasse is reset.

I'm using sqlite3 with DataMapper

From DataMapper init file

DataMapper.setup(:default, "sqlite3://#{Dir.pwd}/main.db")

<my object here>

DataMapper.finalize
DataMapper.auto_upgrade!

/config.ru

require './App'
require 'rubygems'

run Sinatra::Application

What could be the reason? Thanks


Solution

  • Instance data is dropped during OpenShift deploys. Persistent data should be stored in the location specified by the environment variable $OPENSHIFT_DATA_DIR. Move your database file there.