This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://gist.github.com/belt/c8f7b1c45834ce6fa485 | |
desc 'Create a db/extracted_data.sql file for a given entity' | |
namespace :db do | |
namespace :grep do | |
task associations: :environment do | |
obfuscate_sql if obfuscate | |
Rails.application.eager_load! | |
if dump_file_path.blank? | |
puts grep_associations_to_sql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'term/ansicolor' | |
# yeilds a stacktrace for each SQL query | |
# put this file in config/initializers | |
class QueryTrace < ActiveSupport::LogSubscriber | |
include Term::ANSIColor | |
attr_accessor :trace_queries | |
def sql(event) #:nodoc: | |
return unless QueryTrace.enabled? && logger.debug? && Rails.env.development? |