Skip to content

Running migrations in Sinatra

Using Active Record in Sinatra and miss your rails db migration tasks?

Create a /lib/tasks directory from your project root, and copy this file into it:

In your Rakefile, add this line (thanks to this post):

Dir.glob('lib/tasks/*.rake').each { |r| import r }

And, to let the migrations dump your schema.rb file:

RAILS_ROOT = File.dirname(FILE)

And you’re all set.

Post a Comment

Your email is never published nor shared. Required fields are marked *