Class: TestData::DumpsDatabase

Inherits:
Object
  • Object
show all
Defined in:
lib/test_data/dumps_database.rb

Instance Method Summary collapse

Constructor Details

#initializeDumpsDatabase

Returns a new instance of DumpsDatabase.



7
8
9
10
# File 'lib/test_data/dumps_database.rb', line 7

def initialize
  @config = TestData.config
  @records_dump_metadata = RecordsDumpMetadata.new
end

Instance Method Details

#callObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/test_data/dumps_database.rb', line 12

def call
  @records_dump_metadata.call

  dump(
    type: :schema,
    database_name: @config.database_name,
    relative_path: @config.schema_dump_path,
    full_path: @config.schema_dump_full_path
  )

  dump(
    type: :data,
    name: "test data",
    database_name: @config.database_name,
    relative_path: @config.data_dump_path,
    full_path: @config.data_dump_full_path,
    flags: (@config.non_test_data_tables + @config.dont_dump_these_tables).uniq.map { |t| "-T #{t} -T #{t}_id_seq" }.join(" ")
  )

  dump(
    type: :data,
    name: "non-test data",
    database_name: @config.database_name,
    relative_path: @config.non_test_data_dump_path,
    full_path: @config.non_test_data_dump_full_path,
    flags: (@config.non_test_data_tables - @config.dont_dump_these_tables).uniq.map { |t| "-t #{t}" }.join(" ")
  )
end