Module: FIDIUS::Common::Db

Defined in:
lib/fidius-common/yamldb.rb

Overview

Provides methods for the export/import of database dumps to/from YAML.

Class Method Summary collapse

Class Method Details

.export(config_filename, db_entry, target_dir = "", timestamp = true) ⇒ Object

Exports database schema and content to yml file. This should work for all ActiveRecord database adapters.

Parameters:

  • path (String)

    to yml file with database configuration

  • name (String)

    of the db to export, must match an entry in the yml configuration file.

  • target (String)

    dir where the exported data should be stored

  • create (Boolean)

    target dir with timestamp in the dirname



16
17
18
19
# File 'lib/fidius-common/yamldb.rb', line 16

def self.export(config_filename, db_entry, target_dir = "", timestamp = true)
  dumper = SerializationHelper::Base.new(YamlDb::Helper, config_filename, db_entry)
  dumper.dump(target_dir, timestamp)
end

.import(config_filename, db_entry, import_dir) ⇒ Object

Imports the content of a previously exported yml file.

Parameters:

  • path (String)

    to yml file with database configuration

  • name (String)

    of the db to export, must match an entry in the yml configuration file.

  • dir (String)

    to the previously exported yml file



26
27
28
29
# File 'lib/fidius-common/yamldb.rb', line 26

def self.import(config_filename, db_entry, import_dir)
  loader = SerializationHelper::Base.new(YamlDb::Helper, config_filename, db_entry)
  loader.load(import_dir)
end