Module: PerconaMigrations

Extended by:
PerconaMigrations
Included in:
PerconaMigrations
Defined in:
lib/percona_migrations.rb,
lib/percona_migrations/runners.rb,
lib/percona_migrations/version.rb,
lib/percona_migrations/runners/sql.rb,
lib/percona_migrations/runners/base.rb,
lib/percona_migrations/helper_methods.rb,
lib/percona_migrations/runners/percona.rb

Defined Under Namespace

Modules: HelperMethods, Runners

Constant Summary collapse

VERSION =
"0.0.5"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#allow_sql=(value) ⇒ Object (writeonly)

Sets the attribute allow_sql

Parameters:

  • value

    the value to set the attribute allow_sql to.



46
47
48
# File 'lib/percona_migrations.rb', line 46

def allow_sql=(value)
  @allow_sql = value
end

#database_configObject



74
75
76
# File 'lib/percona_migrations.rb', line 74

def database_config
  @database_config || raise('PerconaMigrations.database_config is not set.')
end

#loggerObject



82
83
84
85
86
87
88
89
90
91
# File 'lib/percona_migrations.rb', line 82

def logger
  unless defined? @logger
    @logger = Logger.new($stdout)
    @logger.formatter = proc do |severity, datetime, progname, msg|
      "[percona-migrations] #{msg}\n"
    end
  end

  @logger
end

Instance Method Details

#allow_sql?Boolean

Returns:

  • (Boolean)


78
79
80
# File 'lib/percona_migrations.rb', line 78

def allow_sql?
  !!@allow_sql
end

#configObject



48
49
50
51
52
53
54
# File 'lib/percona_migrations.rb', line 48

def config
  if block_given?
    yield @config
  else
    @config
  end
end

#pt_schema_tool_args(options: {}) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/percona_migrations.rb', line 56

def pt_schema_tool_args(options: {})
  @config.members.map do |key|
    val = options.key?(key) ? options[key] : config[key]
    arg = key.to_s.gsub(/_/,'-')

    case val
    when nil
      nil
    when true
      "--#{arg}"
    when false
      "--no-#{arg}"
    else
      "--#{arg} #{Shellwords.escape(val)}"
    end
  end.compact.join(' ')
end