Module: DatabaseConsistency

Defined in:
lib/database_consistency.rb,
lib/database_consistency/errors.rb,
lib/database_consistency/helper.rb,
lib/database_consistency/report.rb,
lib/database_consistency/version.rb,
lib/database_consistency/rescue_error.rb,
lib/database_consistency/configuration.rb,
lib/database_consistency/debug_context.rb,
lib/database_consistency/report_builder.rb,
lib/database_consistency/databases/factory.rb,
lib/database_consistency/writers/base_writer.rb,
lib/database_consistency/writers/simple/base.rb,
lib/database_consistency/writers/todo_writer.rb,
lib/database_consistency/databases/types/base.rb,
lib/database_consistency/writers/autofix/base.rb,
lib/database_consistency/checkers/base_checker.rb,
lib/database_consistency/writers/simple_writer.rb,
lib/database_consistency/databases/types/sqlite.rb,
lib/database_consistency/writers/autofix_writer.rb,
lib/database_consistency/processors/base_processor.rb,
lib/database_consistency/processors/enums_processor.rb,
lib/database_consistency/processors/models_processor.rb,
lib/database_consistency/processors/columns_processor.rb,
lib/database_consistency/processors/indexes_processor.rb,
lib/database_consistency/writers/simple/missing_table.rb,
lib/database_consistency/writers/simple/possible_null.rb,
lib/database_consistency/writers/autofix/migration_base.rb,
lib/database_consistency/writers/simple/default_message.rb,
lib/database_consistency/writers/simple/redundant_index.rb,
lib/database_consistency/processors/validators_processor.rb,
lib/database_consistency/writers/autofix/redundant_index.rb,
lib/database_consistency/writers/simple/small_primary_key.rb,
lib/database_consistency/processors/associations_processor.rb,
lib/database_consistency/writers/autofix/helpers/migration.rb,
lib/database_consistency/writers/simple/inconsistent_types.rb,
lib/database_consistency/writers/autofix/inconsistent_types.rb,
lib/database_consistency/writers/simple/missing_foreign_key.rb,
lib/database_consistency/writers/simple/three_state_boolean.rb,
lib/database_consistency/checkers/enum_checkers/enum_checker.rb,
lib/database_consistency/writers/autofix/missing_foreign_key.rb,
lib/database_consistency/writers/simple/missing_unique_index.rb,
lib/database_consistency/checkers/index_checkers/index_checker.rb,
lib/database_consistency/checkers/model_checkers/model_checker.rb,
lib/database_consistency/writers/simple/inconsistent_enum_type.rb,
lib/database_consistency/writers/simple/redundant_unique_index.rb,
lib/database_consistency/writers/simple/null_constraint_missing.rb,
lib/database_consistency/checkers/column_checkers/column_checker.rb,
lib/database_consistency/writers/autofix/null_constraint_missing.rb,
lib/database_consistency/writers/simple/length_validator_missing.rb,
lib/database_consistency/checkers/enum_checkers/enum_type_checker.rb,
lib/database_consistency/writers/simple/association_missing_index.rb,
lib/database_consistency/writers/simple/missing_association_class.rb,
lib/database_consistency/processors/validators_fractions_processor.rb,
lib/database_consistency/writers/autofix/association_missing_index.rb,
lib/database_consistency/writers/simple/missing_foreign_key_cascade.rb,
lib/database_consistency/checkers/column_checkers/enum_value_checker.rb,
lib/database_consistency/writers/simple/has_one_missing_unique_index.rb,
lib/database_consistency/writers/simple/length_validator_lower_limit.rb,
lib/database_consistency/checkers/index_checkers/unique_index_checker.rb,
lib/database_consistency/writers/autofix/has_one_missing_unique_index.rb,
lib/database_consistency/writers/simple/implicit_order_column_missing.rb,
lib/database_consistency/writers/simple/missing_uniqueness_validation.rb,
lib/database_consistency/checkers/model_checkers/missing_table_checker.rb,
lib/database_consistency/checkers/validator_checkers/validator_checker.rb,
lib/database_consistency/writers/simple/length_validator_greater_limit.rb,
lib/database_consistency/checkers/index_checkers/redundant_index_checker.rb,
lib/database_consistency/writers/simple/null_constraint_misses_validator.rb,
lib/database_consistency/checkers/column_checkers/null_constraint_checker.rb,
lib/database_consistency/writers/simple/redundant_case_insensitive_option.rb,
lib/database_consistency/checkers/association_checkers/association_checker.rb,
lib/database_consistency/checkers/association_checkers/foreign_key_checker.rb,
lib/database_consistency/checkers/column_checkers/primary_key_type_checker.rb,
lib/database_consistency/checkers/column_checkers/implicit_ordering_checker.rb,
lib/database_consistency/checkers/column_checkers/length_constraint_checker.rb,
lib/database_consistency/writers/simple/association_missing_null_constraint.rb,
lib/database_consistency/checkers/association_checkers/missing_index_checker.rb,
lib/database_consistency/checkers/column_checkers/three_state_boolean_checker.rb,
lib/database_consistency/writers/simple/enum_values_inconsistent_with_ar_enum.rb,
lib/database_consistency/checkers/association_checkers/foreign_key_type_checker.rb,
lib/database_consistency/checkers/index_checkers/redundant_unique_index_checker.rb,
lib/database_consistency/writers/simple/enum_values_inconsistent_with_inclusion.rb,
lib/database_consistency/checkers/validator_checkers/missing_unique_index_checker.rb,
lib/database_consistency/checkers/association_checkers/foreign_key_cascade_checker.rb,
lib/database_consistency/writers/simple/null_constraint_association_misses_validator.rb,
lib/database_consistency/checkers/validators_fraction_checkers/column_presence_checker.rb,
lib/database_consistency/checkers/association_checkers/missing_association_class_checker.rb,
lib/database_consistency/writers/simple/association_foreign_type_missing_null_constraint.rb,
lib/database_consistency/checkers/validators_fraction_checkers/validators_fraction_checker.rb,
lib/database_consistency/checkers/validator_checkers/case_sensitive_unique_validation_checker.rb

Overview

The root module

Defined Under Namespace

Modules: Checkers, Databases, Errors, Helper, Processors, Writers Classes: Configuration, DebugContext, ReportBuilder, RescueError

Constant Summary collapse

Report =
ReportBuilder.define(
  Class.new,
  :checker_name,
  :table_or_model_name,
  :column_or_attribute_name,
  :status,
  :error_slug,
  :error_message
)
VERSION =
'1.7.26'

Class Method Summary collapse

Class Method Details

.run(*args, **opts) ⇒ Object

rubocop:disable Metrics/MethodLength



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/database_consistency.rb', line 110

def run(*args, **opts) # rubocop:disable Metrics/MethodLength
  configuration = Configuration.new(*args)
  reports = Processors.reports(configuration)

  if opts[:autofix]
    Writers::AutofixWriter.write(reports, config: configuration)

    0
  elsif opts[:todo]
    Writers::TodoWriter.write(reports, config: configuration)

    0
  else
    Writers::SimpleWriter.write(reports, config: configuration)

    reports.any? { |report| report.status == :fail } || !RescueError.empty? ? 1 : 0
  end
end