percona-migrations-livelink 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c29d8f765c6e4e9390abbb7fdbda4f69b7260ee9
4
- data.tar.gz: c2fbfde2707fd123a5417b4197ba640f7f957f3a
3
+ metadata.gz: 8b7d274d7167e6920a383959a8eb4c239e94ddbd
4
+ data.tar.gz: 60dcfcf9186f425062f5d3ece10a955df6694419
5
5
  SHA512:
6
- metadata.gz: ad946d3a0fffe22be05b9388c0acfcda86f4abd845cc8f019ef3c5e1969e0f356236fddab42df876ab7d2c5b1d7519f464b3e7e9706dccddac6b77aee827f872
7
- data.tar.gz: 48b8a9f219ac990b6606e4556272085f2f70488f3e344d7ee3ccb498859d2ef63130b90fe74f8736d35664cffe66ee2b215638cb6316526e9a4fbf30470c0184
6
+ metadata.gz: 14a5a5b3a3215d72bfcfcae00e7db11be082809ac768374ac20bb3d3a3e84c3ce2aa7ac98bef36ea0e5fd3984cdba00de9a4a8e22fe382673944844693978cc4
7
+ data.tar.gz: 5dbaa2a59ff404b7264dbb279cb13b6b3ed3ba35c52f42f55e3347e4dce1a6c2572fb44552d7950761eeeba9ff069945f307d50cc37d8b0b1108a704794e0c01
@@ -0,0 +1,24 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [0.0.5] - 10-08-2020
8
+ - Allow passing config options to percona_alter_table as a hash
9
+ - Add documentation for config options
10
+ - Create changelog
11
+
12
+ ## [0.0.4] - 18-03-2016
13
+ - Create lib/percona-migrations-livelink.rb
14
+
15
+ ## [0.0.3] - 17-03-2016
16
+ - Fork project from original repo
17
+ - Add support for most pt-online-schema-change config options
18
+ - Set up travis-ci
19
+
20
+ ## [0.0.2] - 12-02-2015
21
+ - Add link to homepage
22
+
23
+ ## [0.0.1] - 12-02-2015
24
+ - First official release tag
data/README.md CHANGED
@@ -48,6 +48,30 @@ class AddAddressToUsers < ActiveRecord::Migration
48
48
  end
49
49
  ```
50
50
 
51
+ ## Configuration
52
+
53
+ Additional config can optionally be passed either in the initializer or in the migration itself
54
+
55
+ ### As a block in the initializer
56
+
57
+ ```ruby
58
+ PerconaMigrations.config do |c|
59
+ c.drop_old_table = false
60
+ c.max_load = 'Threads_running=60'
61
+ end
62
+ ```
63
+
64
+ ### As a hash argument to the `percona_alter_table` command
65
+
66
+ ```ruby
67
+ def up
68
+ commands = columns.map { |name, type| "ADD COLUMN #{name} #{type}" }
69
+ options = { drop_old_table: false, max_load: 'Threads_running=60' }
70
+
71
+ percona_alter_table :users, commands, options: options
72
+ end
73
+ ```
74
+
51
75
  ## Contributing
52
76
 
53
77
  1. Fork it ( https://github.com/[my-github-username]/percona-migrations/fork )
@@ -0,0 +1 @@
1
+ require 'percona_migrations'
@@ -53,12 +53,10 @@ module PerconaMigrations
53
53
  end
54
54
  end
55
55
 
56
- def pt_schema_tool_args
57
-
56
+ def pt_schema_tool_args(options: {})
58
57
  @config.members.map do |key|
59
-
58
+ val = options.key?(key) ? options[key] : config[key]
60
59
  arg = key.to_s.gsub(/_/,'-')
61
- val = @config[key]
62
60
 
63
61
  case val
64
62
  when nil
@@ -5,9 +5,10 @@ module PerconaMigrations
5
5
  true
6
6
  end
7
7
 
8
- def initialize(table_name, commands)
8
+ def initialize(table_name, commands, options: {})
9
9
  @table_name = table_name
10
10
  @commands = commands
11
+ @options = options
11
12
  end
12
13
 
13
14
  def run
@@ -12,8 +12,8 @@ module PerconaMigrations
12
12
  end
13
13
 
14
14
  def run
15
- options = [
16
- PerconaMigrations.pt_schema_tool_args,
15
+ params = [
16
+ PerconaMigrations.pt_schema_tool_args(options: @options),
17
17
  "--alter '#{@commands.join(', ')}'",
18
18
  "-h #{database_config['host']}",
19
19
  "-P #{database_config['port']}",
@@ -23,10 +23,10 @@ module PerconaMigrations
23
23
 
24
24
  password = database_config['password']
25
25
  if password && !password.empty?
26
- options << "-p $PASSWORD"
26
+ params << "-p $PASSWORD"
27
27
  end
28
28
 
29
- run_command(options.reject(&:empty?).join(' '), { 'PASSWORD' => password })
29
+ run_command(params.reject(&:empty?).join(' '), { 'PASSWORD' => password })
30
30
  end
31
31
 
32
32
  private
@@ -35,9 +35,9 @@ module PerconaMigrations
35
35
  PerconaMigrations.database_config
36
36
  end
37
37
 
38
- def run_command(options, env_vars = {})
38
+ def run_command(params, env_vars = {})
39
39
  %w(dry-run execute).each do |mode|
40
- cmd = "#{self.class.percona_command} #{options} --#{mode}"
40
+ cmd = "#{self.class.percona_command} #{params} --#{mode}"
41
41
 
42
42
  log "Running percona command: \"#{cmd}\""
43
43
 
@@ -1,3 +1,3 @@
1
1
  module PerconaMigrations
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -70,4 +70,21 @@ RSpec.describe PerconaMigrations do
70
70
  end
71
71
  end
72
72
  end
73
+
74
+ describe '::pt_schema_tool_args' do
75
+ before do
76
+ subject.instance_eval { @config = @config.class.new }
77
+ subject.config do |c|
78
+ c.statistics = true
79
+ c.drop_old_table = false
80
+ end
81
+ end
82
+
83
+ it 'returns arguments, overriding any conflicting config settings' do
84
+ options = { drop_old_table: true, drop_new_table: false }
85
+ expect(subject.pt_schema_tool_args(options: options)).to eq(
86
+ '--no-drop-new-table --drop-old-table --statistics'
87
+ )
88
+ end
89
+ end
73
90
  end
metadata CHANGED
@@ -1,73 +1,73 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: percona-migrations-livelink
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Varaksin
8
8
  - Geoff Youngs
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-03-18 00:00:00.000000000 Z
12
+ date: 2020-09-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - '>='
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: '3.0'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - '>='
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: '3.0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rake
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - '>='
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
34
  version: '0'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - '>='
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rspec
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ~>
46
+ - - "~>"
47
47
  - !ruby/object:Gem::Version
48
48
  version: 3.2.0
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - ~>
53
+ - - "~>"
54
54
  - !ruby/object:Gem::Version
55
55
  version: 3.2.0
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: pry
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - '>='
60
+ - - ">="
61
61
  - !ruby/object:Gem::Version
62
62
  version: '0'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - '>='
67
+ - - ">="
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
- description:
70
+ description:
71
71
  email:
72
72
  - varaksin86@gmail.com
73
73
  - git@intersect-uk.co.uk
@@ -75,14 +75,16 @@ executables: []
75
75
  extensions: []
76
76
  extra_rdoc_files: []
77
77
  files:
78
- - .gitignore
79
- - .rspec
80
- - .travis.yml
78
+ - ".gitignore"
79
+ - ".rspec"
80
+ - ".travis.yml"
81
+ - CHANGELOG.md
81
82
  - Gemfile
82
83
  - LICENSE.txt
83
84
  - README.md
84
85
  - Rakefile
85
86
  - lib/percona-migrations-livelink.rb
87
+ - lib/percona-migrations.rb
86
88
  - lib/percona_migrations.rb
87
89
  - lib/percona_migrations/helper_methods.rb
88
90
  - lib/percona_migrations/runners.rb
@@ -101,24 +103,24 @@ homepage: https://github.com/svarks/percona-migrations
101
103
  licenses:
102
104
  - MIT
103
105
  metadata: {}
104
- post_install_message:
106
+ post_install_message:
105
107
  rdoc_options: []
106
108
  require_paths:
107
109
  - lib
108
110
  required_ruby_version: !ruby/object:Gem::Requirement
109
111
  requirements:
110
- - - '>='
112
+ - - ">="
111
113
  - !ruby/object:Gem::Version
112
114
  version: '0'
113
115
  required_rubygems_version: !ruby/object:Gem::Requirement
114
116
  requirements:
115
- - - '>='
117
+ - - ">="
116
118
  - !ruby/object:Gem::Version
117
119
  version: '0'
118
120
  requirements: []
119
- rubyforge_project:
120
- rubygems_version: 2.0.14
121
- signing_key:
121
+ rubyforge_project:
122
+ rubygems_version: 2.5.2.2
123
+ signing_key:
122
124
  specification_version: 4
123
125
  summary: Allows to use percona in rails migrations.
124
126
  test_files: