Class: DBPurger::PlanValidator

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/db-purger/plan_validator.rb

Overview

DBPurger::PlanValidator is used to ensure that all tables in the database are part of the purge plan.

It verifies that all table definitions are correct as well, checking that child/parent fields are part
of the table.

Instance Method Summary collapse

Constructor Details

#initialize(database, plan) ⇒ PlanValidator

Returns a new instance of PlanValidator.



14
15
16
17
# File 'lib/db-purger/plan_validator.rb', line 14

def initialize(database, plan)
  @database = database
  @plan = plan
end

Instance Method Details

#missing_tablesObject

tables that are part of the database but not part of the plan



20
21
22
# File 'lib/db-purger/plan_validator.rb', line 20

def missing_tables
  database_table_names - @plan.table_names.map(&:to_s)
end

#unknown_tablesObject

tables that are part of the plan put not part of the database



25
26
27
# File 'lib/db-purger/plan_validator.rb', line 25

def unknown_tables
  @plan.table_names.map(&:to_s) - database_table_names
end