I can’t seem to find a gem or example of anyone using Rails-style rake tasks within a Sinatra app. I would like to clean out my migrations folder and am looking to do something like explained here: When (if) to consolidate ActiveRecord migrations?
Share
Why Sinatra Doesn’t Do What You Want “Out of the Box”
Sinatra isn’t a multi-layer framework in the same way as Ruby on Rails. Specifically, while you can certainly add a database layer to a Sinatra application, it doesn’t support ActiveRecord or Rails migrations “out of the box.”
If you’re looking for standard Rails rake tasks and migration support, why not just use Rails? Sinatra is terrific, but it is not a drop-in replacement for Rails.
So You Want Database-Centric Rake Tasks…
If your database connectivity comes from a gem, see if the gem’s project has a Rakefile you can re-purpose for your application. For example, the sinatra-activerecord gem provides instructions for adding related Rake tasks to your Rakefile.
If you rolled your own database connectivity, then you’re probably going to have to roll your own Rake tasks as well. The documentation for Rake is extensive, and the features should allow you to automate the tasks you need.