Sha256: 4806b8c1d09e091f996b70e892afc5cce7a920a7deb19a264dc31e0eb458c038
Contents?: true
Size: 757 Bytes
Versions: 3
Compression:
Stored size: 757 Bytes
Contents
desc 'Finds unique validations in models that do not have DB indexes.' task :inspect_unique_validations => :environment do inspector = UniqueValidationInspector::Inspector.new Rails.application defined_unique_validations = inspector.defined_unique_validations puts puts "You have the following unique validations:" defined_unique_validations.each do |item| model = item[:model] puts puts "Model '#{model.name}':" item[:validators].each do |validation| scope = validation.options[:scope] attributes = validation.attributes index_exists = inspector.defined_unique_indexes(model.table_name, attributes, scope) puts "#{attributes} (scope '#{scope}'). Index exists: #{index_exists}" end end puts end
Version data entries
3 entries across 3 versions & 1 rubygems