percona_migrator 0.1.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -19
- data/README.md +7 -14
- data/RELEASING.md +17 -0
- data/lib/active_record/connection_adapters/percona_adapter.rb +9 -7
- data/lib/percona_migrator/cli_generator.rb +5 -0
- data/lib/percona_migrator/runner.rb +0 -6
- data/lib/percona_migrator/version.rb +1 -1
- data/percona_migrator.gemspec +2 -8
- metadata +15 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 686c3a5b5ab858a587451fba1c6aa0b934f1cf9c
|
4
|
+
data.tar.gz: d01ece64414481d9b43a143a16f748ce134afc7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 104039977e6a970cad93bcb93e7ff628a2a00c0a10715543daaf9915fca08a1bf6e1643dc2e2e34e947f494f43abc9662c62a0a3e53ae9c98a0500abf9a9576e
|
7
|
+
data.tar.gz: f7e205f53c0cfd327dd293d0357b8e1e85b64ddf0a7a2cca14679a22607e3d5c8d1731757cb0ed1a25d83c38f31795fe23a74fc9cfd82af5cad1f42e67ce4e84
|
data/CHANGELOG.md
CHANGED
@@ -6,30 +6,20 @@ Please follow the format in [Keep a Changelog](http://keepachangelog.com/)
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
-
|
10
|
-
### Changed
|
11
|
-
### Removed
|
12
|
-
### Fixed
|
13
|
-
|
14
|
-
## [0.1.1] - 2017-03-10
|
9
|
+
## [1.0.0] - 2016-11-30
|
15
10
|
|
16
11
|
### Added
|
17
12
|
|
13
|
+
- Show pt-online-schema-change's stdout while the migration is running instead
|
14
|
+
of at then and all at once.
|
18
15
|
- Store pt-online-schema-change's stderr to percona_migrator_error.log in the
|
19
16
|
default Rails tmp folder.
|
20
|
-
- Allow configuring the tmp directory where the error log gets written into
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
- No longer a hard dependency on mysql2 0.3.20. Will accept 0.3.20 or any
|
27
|
-
higher patch revisions.
|
28
|
-
|
29
|
-
### Fixed
|
30
|
-
|
31
|
-
- Output pt-online-schema-change's stdout while the migration is running instead
|
32
|
-
of all of it at the end.
|
17
|
+
- Allow configuring the tmp directory where the error log gets written into,
|
18
|
+
with the `tmp_path` configuration setting.
|
19
|
+
- Support for ActiveRecord 4.0. Adds the following migration methods:
|
20
|
+
- #rename_index, #change_column_null, #add_reference, #remove_reference,
|
21
|
+
#set_field_encoding, #add_timestamps, #remove_timestamps, #rename_table,
|
22
|
+
#rename_column
|
33
23
|
|
34
24
|
## [0.1.0.rc.7] - 2016-09-15
|
35
25
|
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# Percona Migrator [![Build Status](https://travis-ci.org/redbooth/percona_migrator.svg?branch=master)](https://travis-ci.org/redbooth/percona_migrator) [![Code Climate](https://codeclimate.com/github/redbooth/percona_migrator/badges/gpa.svg)](https://codeclimate.com/github/redbooth/percona_migrator)
|
2
2
|
|
3
|
-
|
3
|
+
Percona Migrator is an **ActiveRecord connection adapter** that allows running
|
4
4
|
**MySQL online and non-blocking DDL** through `ActiveRecord::Migration` without needing
|
5
5
|
to use a different DSL other than Rails' migrations DSL.
|
6
6
|
|
@@ -9,17 +9,9 @@ It uses `pt-online-schema-change` command-line tool of
|
|
9
9
|
Toolkit](https://www.percona.com/doc/percona-toolkit/2.0/pt-online-schema-change.html)
|
10
10
|
which runs MySQL alter table statements without downtime.
|
11
11
|
|
12
|
-
## Rename from "Percona Migrator"
|
13
|
-
|
14
|
-
This project was formerly known as "Percona Migrator", but this incurs in an
|
15
|
-
infringement of Percona's trade mark policy and thus has to be renamed. Said
|
16
|
-
name is likely to cause confusion as to the source of the wrapper.
|
17
|
-
|
18
|
-
The next major versions will use "Departure" as gem name.
|
19
|
-
|
20
12
|
## Installation
|
21
13
|
|
22
|
-
|
14
|
+
Percona Migrator relies on `pt-online-schema-change` from [Percona
|
23
15
|
Toolkit](https://www.percona.com/doc/percona-toolkit/2.0/pt-online-schema-change.html)
|
24
16
|
|
25
17
|
### Mac
|
@@ -70,7 +62,7 @@ migration.
|
|
70
62
|
### LHM support
|
71
63
|
|
72
64
|
If you moved to Soundcloud's [Lhm](https://github.com/soundcloud/lhm) already,
|
73
|
-
we got you covered.
|
65
|
+
we got you covered. Percona Migrator overrides Lhm's DSL so that all the alter
|
74
66
|
statements also go through `pt-online-schema-change` as well.
|
75
67
|
|
76
68
|
You can keep your Lhm migrations and start using Rails migration's DSL back
|
@@ -91,7 +83,7 @@ It's strongly recommended to name it after this gems name, such as
|
|
91
83
|
|
92
84
|
## How it works
|
93
85
|
|
94
|
-
When booting your Rails app,
|
86
|
+
When booting your Rails app, Percona Migrator extends the
|
95
87
|
`ActiveRecord::Migration#migrate` method to reset the connection and reestablish
|
96
88
|
it using the `PerconaAdapter` instead of the one you defined in your
|
97
89
|
`config/database.yml`.
|
@@ -129,7 +121,8 @@ git commits and tags, and push the `.gem` file to
|
|
129
121
|
## Contributing
|
130
122
|
|
131
123
|
Bug reports and pull requests are welcome on GitHub at
|
132
|
-
https://github.com/redbooth/percona_migrator.
|
124
|
+
https://github.com/redbooth/percona_migrator. They need to be opened against
|
125
|
+
`master` or `v3.2` only if the changes fix a bug in Rails 3.2 apps.
|
133
126
|
|
134
127
|
Please note that this project is released with a Contributor Code of Conduct. By
|
135
128
|
participating in this project you agree to abide by its terms.
|
data/RELEASING.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Releasing Percona Migrator
|
2
|
+
|
3
|
+
All releases come from the master branch. All other branches won't be maintained
|
4
|
+
and will receive bug fix releases only.
|
5
|
+
|
6
|
+
In order to give support to a new major Rails version, we'll branch off of
|
7
|
+
master, name it following the Rails repo convention, such as `v4.2`, and
|
8
|
+
we'll keep it open for bug fixes.
|
9
|
+
|
10
|
+
1. Update `lib/percona_migrator/version.rb` accordingly
|
11
|
+
2. Review the `CHANGELOG.md` and add a new section following the format
|
12
|
+
`[version] - YYYY-MM-DD`. We conform to the guidelines of
|
13
|
+
http://keepachangelog.com/
|
14
|
+
3. Commit the changes with the message `Prepare release VERSION`
|
15
|
+
4. Execute the release rake task as `bundle exec rake release`. It creates the
|
16
|
+
tag, builds and pushes the gem to Rubygems.
|
17
|
+
5. Announce it! :tada:
|
@@ -5,12 +5,14 @@ require 'percona_migrator'
|
|
5
5
|
require 'forwardable'
|
6
6
|
|
7
7
|
module ActiveRecord
|
8
|
-
|
8
|
+
module ConnectionHandling
|
9
9
|
# Establishes a connection to the database that's used by all Active
|
10
10
|
# Record objects.
|
11
|
-
def
|
11
|
+
def percona_connection(config)
|
12
12
|
mysql2_connection = mysql2_connection(config)
|
13
13
|
|
14
|
+
config[:username] = 'root' if config[:username].nil?
|
15
|
+
|
14
16
|
verbose = ActiveRecord::Migration.verbose
|
15
17
|
percona_logger = PerconaMigrator::LoggerFactory.build(verbose: verbose)
|
16
18
|
cli_generator = PerconaMigrator::CliGenerator.new(config)
|
@@ -45,7 +47,7 @@ module ActiveRecord
|
|
45
47
|
|
46
48
|
ADAPTER_NAME = 'Percona'.freeze
|
47
49
|
|
48
|
-
def_delegators :mysql_adapter, :last_inserted_id, :each_hash
|
50
|
+
def_delegators :mysql_adapter, :last_inserted_id, :each_hash, :set_field_encoding
|
49
51
|
|
50
52
|
def initialize(connection, _logger, connection_options, _config)
|
51
53
|
super
|
@@ -59,7 +61,7 @@ module ActiveRecord
|
|
59
61
|
end
|
60
62
|
alias :exec_update :exec_delete
|
61
63
|
|
62
|
-
def exec_insert(sql, name, binds)
|
64
|
+
def exec_insert(sql, name, binds, pk = nil, sequence_name = nil)
|
63
65
|
execute(to_sql(sql, binds), name)
|
64
66
|
end
|
65
67
|
|
@@ -77,7 +79,7 @@ module ActiveRecord
|
|
77
79
|
# Executes a SELECT query and returns an array of record hashes with the
|
78
80
|
# column names as keys and column values as values.
|
79
81
|
def select(sql, name = nil, binds = [])
|
80
|
-
exec_query(sql, name, binds)
|
82
|
+
exec_query(sql, name, binds)
|
81
83
|
end
|
82
84
|
|
83
85
|
# Returns true, as this adapter supports migrations
|
@@ -85,8 +87,8 @@ module ActiveRecord
|
|
85
87
|
true
|
86
88
|
end
|
87
89
|
|
88
|
-
def new_column(field, default, type, null, collation)
|
89
|
-
Column.new(field, default, type, null, collation)
|
90
|
+
def new_column(field, default, type, null, collation, extra = "")
|
91
|
+
Column.new(field, default, type, null, collation, extra)
|
90
92
|
end
|
91
93
|
|
92
94
|
# Adds a new index to the table
|
@@ -28,6 +28,10 @@ module PerconaMigrator
|
|
28
28
|
|
29
29
|
# Generates the equivalent Percona's pt-online-schema-change command to the
|
30
30
|
# given SQL statement
|
31
|
+
#
|
32
|
+
# --no-check-alter is used to allow running CHANGE COLUMN statements. For
|
33
|
+
# more details, check: www.percona.com/doc/percona-toolkit/2.2/pt-online-schema-change.html#cmdoption-pt-online-schema-change--[no]check-alter
|
34
|
+
#
|
31
35
|
class CliGenerator # Command
|
32
36
|
BASE_COMMAND = 'pt-online-schema-change'
|
33
37
|
BASE_OPTIONS = %w(
|
@@ -35,6 +39,7 @@ module PerconaMigrator
|
|
35
39
|
--statistics
|
36
40
|
--recursion-method=none
|
37
41
|
--alter-foreign-keys-method=auto
|
42
|
+
--no-check-alter
|
38
43
|
)
|
39
44
|
|
40
45
|
# Constructor
|
@@ -70,17 +70,11 @@ module PerconaMigrator
|
|
70
70
|
#
|
71
71
|
# @yield
|
72
72
|
def logging
|
73
|
-
log_deprecations
|
74
73
|
log_started
|
75
74
|
yield
|
76
75
|
log_finished
|
77
76
|
end
|
78
77
|
|
79
|
-
def log_deprecations
|
80
|
-
logger.write("\n")
|
81
|
-
logger.write("[DEPRECATION] This gem has been renamed to Departure and will no longer be supported. Please switch to Departure as soon as possible.")
|
82
|
-
end
|
83
|
-
|
84
78
|
# Logs when the execution started
|
85
79
|
def log_started
|
86
80
|
logger.write("\n")
|
data/percona_migrator.gemspec
CHANGED
@@ -15,17 +15,11 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.homepage = 'http://github.com/redbooth/percona_migrator'
|
16
16
|
spec.license = 'MIT'
|
17
17
|
|
18
|
-
spec.post_install_message = <<-MESSAGE
|
19
|
-
! The Percona_migrator gem has been deprecated and has been replaced by Departure.
|
20
|
-
! See: https://rubygems.org/gems/departure
|
21
|
-
! And: https://github.com/redbooth/departure
|
22
|
-
MESSAGE
|
23
|
-
|
24
18
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
19
|
spec.require_paths = ['lib']
|
26
20
|
|
27
|
-
spec.add_runtime_dependency 'rails', '
|
28
|
-
spec.add_runtime_dependency 'mysql2', '
|
21
|
+
spec.add_runtime_dependency 'rails', '>= 3.2.22', '~> 4.0.0'
|
22
|
+
spec.add_runtime_dependency 'mysql2', '0.3.20'
|
29
23
|
|
30
24
|
spec.add_development_dependency 'bundler', '~> 1.10'
|
31
25
|
spec.add_development_dependency 'rake', '~> 10.0'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: percona_migrator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya Zayats
|
@@ -11,34 +11,40 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2016-11-30 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|
18
18
|
requirement: !ruby/object:Gem::Requirement
|
19
19
|
requirements:
|
20
|
-
- - "
|
20
|
+
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: 3.2.22
|
23
|
+
- - "~>"
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: 4.0.0
|
23
26
|
type: :runtime
|
24
27
|
prerelease: false
|
25
28
|
version_requirements: !ruby/object:Gem::Requirement
|
26
29
|
requirements:
|
27
|
-
- - "
|
30
|
+
- - ">="
|
28
31
|
- !ruby/object:Gem::Version
|
29
32
|
version: 3.2.22
|
33
|
+
- - "~>"
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 4.0.0
|
30
36
|
- !ruby/object:Gem::Dependency
|
31
37
|
name: mysql2
|
32
38
|
requirement: !ruby/object:Gem::Requirement
|
33
39
|
requirements:
|
34
|
-
- -
|
40
|
+
- - '='
|
35
41
|
- !ruby/object:Gem::Version
|
36
42
|
version: 0.3.20
|
37
43
|
type: :runtime
|
38
44
|
prerelease: false
|
39
45
|
version_requirements: !ruby/object:Gem::Requirement
|
40
46
|
requirements:
|
41
|
-
- -
|
47
|
+
- - '='
|
42
48
|
- !ruby/object:Gem::Version
|
43
49
|
version: 0.3.20
|
44
50
|
- !ruby/object:Gem::Dependency
|
@@ -141,6 +147,7 @@ files:
|
|
141
147
|
- Gemfile
|
142
148
|
- LICENSE.txt
|
143
149
|
- README.md
|
150
|
+
- RELEASING.md
|
144
151
|
- Rakefile
|
145
152
|
- bin/console
|
146
153
|
- bin/setup
|
@@ -168,10 +175,7 @@ homepage: http://github.com/redbooth/percona_migrator
|
|
168
175
|
licenses:
|
169
176
|
- MIT
|
170
177
|
metadata: {}
|
171
|
-
post_install_message:
|
172
|
-
! The Percona_migrator gem has been deprecated and has been replaced by Departure.
|
173
|
-
! See: https://rubygems.org/gems/departure
|
174
|
-
! And: https://github.com/redbooth/departure
|
178
|
+
post_install_message:
|
175
179
|
rdoc_options: []
|
176
180
|
require_paths:
|
177
181
|
- lib
|
@@ -187,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
187
191
|
version: '0'
|
188
192
|
requirements: []
|
189
193
|
rubyforge_project:
|
190
|
-
rubygems_version: 2.
|
194
|
+
rubygems_version: 2.4.5.1
|
191
195
|
signing_key:
|
192
196
|
specification_version: 4
|
193
197
|
summary: pt-online-schema-change runner for ActiveRecord migrations
|