There are tons of questions similar to this one that talk about rails plugins as a solution, but I don't use rails, read on for
I have a Rakefile in a sinatra project that allows me to rake db:migrate . It will do my migration perfectly, but I would like to pass this flag (or write a new rake command), which does the same, but outputs SQL to STDOUT and does not commit the changes to the database. Does anyone know how to do this?
My first thought was to try running ActiveRecord and see if I can get SQL at all, but that doesn't work! Any ideas?
namespace :db do task :migrate_sql do require 'logger' ActiveRecord::Base.logger = Logger.new(STDOUT) Rake::Task['db:migrate'].invoke
source share