class DbSubsetter::Database
A database to be exported from/to
Public Class Methods
new(exporter)
click to toggle source
# File lib/db_subsetter/database.rb, line 4 def initialize(exporter) @exporter = exporter @tables = {} all_table_names.each { |table_name| @tables[table_name] = Table.new(table_name, self, @exporter) } end
Public Instance Methods
all_table_names()
click to toggle source
Raw list of names of all tables in the database.
# File lib/db_subsetter/database.rb, line 23 def all_table_names @all_table_names ||= ActiveRecord::Base.connection.tables - ['ar_internal_metadata'] end
exportability_issues()
click to toggle source
# File lib/db_subsetter/database.rb, line 42 def exportability_issues exported_tables.reject(&:exportable?).map { |table| [table.name, table.exportability_issues] }.to_h end
exportable?()
click to toggle source
# File lib/db_subsetter/database.rb, line 37 def exportable? puts "Verifying table exportability ...\n\n" if @exporter.verbose? exported_tables.reject(&:exportable?).count.zero? end
exported_tables()
click to toggle source
# File lib/db_subsetter/database.rb, line 18 def exported_tables tables.reject(&:ignored?) end
filtered_row_counts()
click to toggle source
Used in debugging/reporting
# File lib/db_subsetter/database.rb, line 33 def filtered_row_counts tables.map { |table| [table.name, table.filtered_row_count] }.to_h end
find_table(name)
click to toggle source
# File lib/db_subsetter/database.rb, line 10 def find_table(name) @tables[name.to_s] end
tables()
click to toggle source
# File lib/db_subsetter/database.rb, line 14 def tables @tables.values end
total_row_counts()
click to toggle source
Used in debugging/reporting
# File lib/db_subsetter/database.rb, line 28 def total_row_counts tables.map { |table| [table.name, table.total_row_count] }.to_h end