Sha256: 1af6886105dce6948ce7216d4f5fc0a936e368d76c66264de38c73fcf5414f92

Contents?: true

Size: 764 Bytes

Versions: 1

Compression:

Stored size: 764 Bytes

Contents

require "active_record_doctor/compatibility"
require "active_record_doctor/printers/io_printer"

module ActiveRecordDoctor
  module Tasks
    class UndefinedTableReferences
      include Compatibility

      def self.run
        new.run
      end

      def initialize(printer: ActiveRecordDoctor::Printers::IOPrinter.new)
        @printer = printer
      end

      def run
        @printer.print_undefined_table_references(undefined_table_references)
        undefined_table_references.present? ? 1 : 0
      end

      private

      def undefined_table_references
        Rails.application.eager_load!

        ActiveRecord::Base.subclasses.reject do |model|
          model.connection.tables.include?(model.table_name)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_record_doctor-1.4.0 lib/active_record_doctor/tasks/undefined_table_references.rb