Class: PerconaMigrator::ConnectionDetails
- Inherits:
-
Object
- Object
- PerconaMigrator::ConnectionDetails
- Defined in:
- lib/percona_migrator/connection_details.rb
Overview
Holds the parameters of the DB connection and formats them to string
Instance Method Summary collapse
-
#database ⇒ String
TODO: Doesn’t the abstract adapter already handle this somehow? Returns the database name.
-
#initialize(connection_data) ⇒ ConnectionDetails
constructor
Constructor.
-
#password_argument ⇒ String
Returns the password fragment of the details string if a password is passed.
-
#to_s ⇒ String
Returns the details formatted as an string to be used with pt-online-schema-change.
Constructor Details
#initialize(connection_data) ⇒ ConnectionDetails
Constructor
8 9 10 |
# File 'lib/percona_migrator/connection_details.rb', line 8 def initialize(connection_data) @connection_data = connection_data end |
Instance Method Details
#database ⇒ String
TODO: Doesn’t the abstract adapter already handle this somehow? Returns the database name. If PERCONA_DB_NAME is passed its value will be used instead
Returns the database name
27 28 29 |
# File 'lib/percona_migrator/connection_details.rb', line 27 def database ENV.fetch('PERCONA_DB_NAME', connection_data[:database]) end |
#password_argument ⇒ String
Returns the password fragment of the details string if a password is passed
34 35 36 37 38 39 40 |
# File 'lib/percona_migrator/connection_details.rb', line 34 def password_argument if password.present? "-p #{password}" else '' end end |
#to_s ⇒ String
Returns the details formatted as an string to be used with pt-online-schema-change. It follows the mysql client’s format.
16 17 18 |
# File 'lib/percona_migrator/connection_details.rb', line 16 def to_s @to_s ||= "-h #{host} -u #{user} #{password_argument}" end |