Class: RailsParallel::Runner::Schema

Inherits:
Object
  • Object
show all
Includes:
Forks
Defined in:
lib/rails_parallel/runner/schema.rb

Instance Method Summary collapse

Methods included from Forks

#before_exit, #check_status, #fork_and_run, #wait_any, #wait_for

Constructor Details

#initialize(file) ⇒ Schema

Returns a new instance of Schema.



9
10
11
# File 'lib/rails_parallel/runner/schema.rb', line 9

def initialize(file)
  @file = file
end

Instance Method Details

#load_db(number) ⇒ Object



30
31
32
33
34
35
36
37
38
39
# File 'lib/rails_parallel/runner/schema.rb', line 30

def load_db(number)
  update_db_config(number)
  if schema_loaded?
    reconnect
    false
  else
    schema_load
    true
  end
end

#load_main_dbObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rails_parallel/runner/schema.rb', line 13

def load_main_db
  if load_db(1)
    failed = 0
    ObjectSpace.each_object(Class) do |klass|
      next unless klass < ActiveRecord::Base

      klass.reset_column_information
      begin
        klass.columns
      rescue StandardError => e
        failed += 1
        raise e if failed > 3
      end
    end
  end
end