Sha256: 110367826393e88dc9623fbf6f19a98378b45936aefa069ebee02dc64c1b90b0

Contents?: true

Size: 866 Bytes

Versions: 5

Compression:

Stored size: 866 Bytes

Contents

module Storey
  class SqlDumper

    easy_class_to_instance

    def initialize(options={})
      @file = options[:file] || File.join(Rails.root, "db", "structure.sql")
    end

    def dump
      `#{command}`
      raise 'Error dumping database' if $?.exitstatus == 1
    end

    private

    def abcs
      @abcs ||= ::ActiveRecord::Base.configurations.with_indifferent_access[Rails.env]
    end

    def search_path
      @search_path ||= abcs[:schema_search_path]
    end

    def database_name
      @database_name ||= Shellwords.escape(abcs[:database])
    end

    def command
      @command ||= BuildsDumpCommand.execute(structure_only: true,
                                             file: @file,
                                             schemas: search_path,
                                             database: database_name)
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
storey-1.0.0 lib/storey/sql_dumper.rb
storey-0.6.0 lib/storey/sql_dumper.rb
storey-0.5.2 lib/storey/sql_dumper.rb
storey-0.5.1 lib/storey/sql_dumper.rb
storey-0.5.0 lib/storey/sql_dumper.rb