What is the correct way to setup database with DataMapper and Sinatra on production server? What is the correct way to setup database with DataMapper and Sinatra on production server? sqlite sqlite

What is the correct way to setup database with DataMapper and Sinatra on production server?


Where and when should finalize be called?

From http://rdoc.info/github/datamapper/dm-core/DataMapper#finalize-class_method

This method should be called after loading all models and plugins.

When deploying the app first time there is no db file on the production server, how do I have it automatically created? Or do I have to create the project.db file manually?

It depends on your hosting arrangement, but the main thing to do is put the running of migrations in a Rake task and run them when the app is deployed. If you're using Sqlite, this would create the database (although on some hosts you are not allowed to update the file system). I don't think it's a good idea to use Sqlite for a production database, but that's your decision.

Since the auto_upgrade! is wrapped in :development block, it won't be called on production server. How am I supposed to upgrade database when I add or remove columns in it?

Use a Rake task. After each deployment you'd run the "db:migrate:up" (or whatever you'd called it) task and it would run the latest migrations. You might get a few ideas from Padrino's Rake tasks for DataMapper