departure 6.1.0 → 6.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +1 -1
- data/.travis.yml +18 -2
- data/CHANGELOG.md +18 -0
- data/README.md +8 -8
- data/RELEASING.md +1 -1
- data/departure.gemspec +9 -4
- data/lib/active_record/connection_adapters/for_alter.rb +91 -0
- data/lib/active_record/connection_adapters/percona_adapter.rb +37 -1
- data/lib/departure.rb +4 -1
- data/lib/departure/alter_argument.rb +9 -3
- data/lib/departure/connection_base.rb +9 -0
- data/lib/departure/connection_details.rb +19 -1
- data/lib/departure/version.rb +1 -1
- data/lib/lhm/column_with_sql.rb +1 -1
- data/test_database.rb +11 -14
- metadata +47 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7379ce58f2dd5726c2844bb8ad94f24f427d5567bf4b96d6252faba6ac9371c3
|
4
|
+
data.tar.gz: 607e8a0fb255e7630e2379f7c3f7907723bad228742905fbefc38a053a22f2f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a16e8fa492148d38370dc86bfc2cc3c46696ba7369c0f07bfe6981c01cdfa93e37286a7394507abbb4cb7e7ed2eed7adb6aa43ea92b193c15743d0469cc09e45
|
7
|
+
data.tar.gz: c01c6cc976f7893c99e3257a3de7075afc004878dc2d04cff15bfd0d344f177669de2be808a67527c39c9ede79b5c8978e85ca797bfecc3258f302f474859995
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
@@ -1,8 +1,24 @@
|
|
1
1
|
language: ruby
|
2
|
+
|
2
3
|
rvm:
|
3
|
-
- 2.
|
4
|
+
- 2.5.5
|
5
|
+
- 2.6.3
|
6
|
+
- 2.7.0
|
7
|
+
|
8
|
+
env:
|
9
|
+
- RAILS_VERSION="~> 6.0.0"
|
10
|
+
- RAILS_VERSION="~> 5.2.0"
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
include:
|
14
|
+
- rvm: 2.4.6
|
15
|
+
env: RAILS_VERSION="~> 5.2.0"
|
16
|
+
|
17
|
+
services:
|
18
|
+
- mysql
|
19
|
+
|
4
20
|
before_install:
|
5
|
-
- sudo apt-key adv --keyserver keys.gnupg.net --recv-keys 8507EFA5
|
21
|
+
- travis_retry sudo apt-key adv --keyserver keys.gnupg.net --recv-keys 8507EFA5
|
6
22
|
- echo "deb http://repo.percona.com/apt `lsb_release -cs` main" | sudo tee -a /etc/apt/sources.list
|
7
23
|
- sudo apt-get update -qq
|
8
24
|
- sudo apt-get install percona-toolkit
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,24 @@ Please follow the format in [Keep a Changelog](http://keepachangelog.com/)
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
### Added
|
10
|
+
|
11
|
+
- Support for ActiveRecord 5.2
|
12
|
+
- Support to batch multiple changes at once with #change_table
|
13
|
+
- Support for connection to MySQL server over SSL
|
14
|
+
|
15
|
+
### Changed
|
16
|
+
|
17
|
+
- Depend only in railties and activerecord instead of rails gem
|
18
|
+
|
19
|
+
### Deprecated
|
20
|
+
### Removed
|
21
|
+
### Fixed
|
22
|
+
|
23
|
+
- Fix support for removing foreign keys
|
24
|
+
|
25
|
+
## [6.1.0] - 2018-02-27
|
26
|
+
|
9
27
|
### Added
|
10
28
|
### Changed
|
11
29
|
|
data/README.md
CHANGED
@@ -99,7 +99,7 @@ $ PERCONA_ARGS='--chunk-time=1' bundle exec rake db:migrate:up VERSION=xxx
|
|
99
99
|
or even mulitple arguments
|
100
100
|
|
101
101
|
```ruby
|
102
|
-
$ PERCONA_ARGS='--chunk-time=1 --critical-load=55' bundle exec rake db:migrate:up VERSION=xxx
|
102
|
+
$ PERCONA_ARGS='--chunk-time=1 --critical-load Threads_running=55' bundle exec rake db:migrate:up VERSION=xxx
|
103
103
|
```
|
104
104
|
|
105
105
|
Use caution when using PERCONA_ARGS with `db:migrate`, as your args will be applied
|
@@ -112,7 +112,7 @@ using `global_percona_args` option.
|
|
112
112
|
|
113
113
|
```ruby
|
114
114
|
Departure.configure do |config|
|
115
|
-
config.global_percona_args = '--chunk-time=1 --critical-load=55'
|
115
|
+
config.global_percona_args = '--chunk-time=1 --critical-load Threads_running=55'
|
116
116
|
end
|
117
117
|
```
|
118
118
|
|
@@ -154,19 +154,19 @@ it using the `DepartureAdapter` instead of the one you defined in your
|
|
154
154
|
|
155
155
|
Then, when any migration DSL methods such as `add_column` or `create_table` are
|
156
156
|
executed, they all go to the
|
157
|
-
[DepartureAdapter](https://github.com/
|
157
|
+
[DepartureAdapter](https://github.com/departurerb/departure/blob/master/lib/active_record/connection_adapters/departure_adapter.rb).
|
158
158
|
There, the methods that require `ALTER TABLE` SQL statements, like `add_column`,
|
159
159
|
are overriden to get executed with
|
160
|
-
[Departure::Runner](https://github.com/
|
160
|
+
[Departure::Runner](https://github.com/departurerb/departure/blob/master/lib/departure/runner.rb),
|
161
161
|
which deals with the `pt-online-schema-change` binary. All the others, like
|
162
162
|
`create_table`, are delegated to the ActiveRecord's built in Mysql2Adapter and
|
163
163
|
so they follow the regular path.
|
164
164
|
|
165
|
-
[Departure::Runner](https://github.com/
|
165
|
+
[Departure::Runner](https://github.com/departurerb/departure/blob/master/lib/departure/runner.rb)
|
166
166
|
spawns a new process that runs the `pt-online-schema-change` binary present in
|
167
|
-
the system, with the
|
167
|
+
the system, with the appropriate arguments for the generated SQL.
|
168
168
|
|
169
|
-
When
|
169
|
+
When any errors occur, an `ActiveRecord::StatementInvalid` exception is
|
170
170
|
raised and the migration is aborted, as all other ActiveRecord connection
|
171
171
|
adapters.
|
172
172
|
|
@@ -191,7 +191,7 @@ git commits and tags, and push the `.gem` file to
|
|
191
191
|
## Contributing
|
192
192
|
|
193
193
|
Bug reports and pull requests are welcome on GitHub at
|
194
|
-
https://github.com/
|
194
|
+
https://github.com/departurerb/departure. They need to be opened against
|
195
195
|
`master` or `v3.2` only if the changes fix a bug in Rails 3.2 apps.
|
196
196
|
|
197
197
|
Please note that this project is released with a Contributor Code of Conduct. By
|
data/RELEASING.md
CHANGED
data/departure.gemspec
CHANGED
@@ -5,11 +5,15 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
|
6
6
|
require 'departure/version'
|
7
7
|
|
8
|
+
# This environment variable is set on CI to facilitate testing with multiple
|
9
|
+
# versions of Rails.
|
10
|
+
RAILS_DEPENDENCY_VERSION = ENV.fetch('RAILS_VERSION', ['>= 5.2.0', '< 6.1'])
|
11
|
+
|
8
12
|
Gem::Specification.new do |spec|
|
9
13
|
spec.name = 'departure'
|
10
14
|
spec.version = Departure::VERSION
|
11
|
-
spec.authors = ['Ilya Zayats', 'Pau Pérez', 'Fran Casas', 'Jorge Morante', 'Enrico Stano', 'Adrian Serafin', 'Kirk Haines']
|
12
|
-
spec.email = ['ilya.zayats@redbooth.com', 'pau.perez@redbooth.com', '
|
15
|
+
spec.authors = ['Ilya Zayats', 'Pau Pérez', 'Fran Casas', 'Jorge Morante', 'Enrico Stano', 'Adrian Serafin', 'Kirk Haines', 'Guillermo Iguaran']
|
16
|
+
spec.email = ['ilya.zayats@redbooth.com', 'pau.perez@redbooth.com', 'nflamel@gmail.com', 'jorge.morante@redbooth.com', 'adrian@softmad.pl', 'wyhaines@gmail.com', 'guilleiguaran@gmail.com']
|
13
17
|
|
14
18
|
spec.summary = %q(pt-online-schema-change runner for ActiveRecord migrations)
|
15
19
|
spec.description = %q(Execute your ActiveRecord migrations with Percona's pt-online-schema-change. Formerly known as Percona Migrator.)
|
@@ -19,8 +23,9 @@ Gem::Specification.new do |spec|
|
|
19
23
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
24
|
spec.require_paths = ['lib']
|
21
25
|
|
22
|
-
spec.add_runtime_dependency '
|
23
|
-
spec.add_runtime_dependency '
|
26
|
+
spec.add_runtime_dependency 'railties', *Array(RAILS_DEPENDENCY_VERSION)
|
27
|
+
spec.add_runtime_dependency 'activerecord', *Array(RAILS_DEPENDENCY_VERSION)
|
28
|
+
spec.add_runtime_dependency 'mysql2', '>= 0.4.0', '<= 0.5.3'
|
24
29
|
|
25
30
|
spec.add_development_dependency 'rake', '~> 10.0'
|
26
31
|
spec.add_development_dependency 'rspec', '~> 3.4', '>= 3.4.0'
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'active_record/connection_adapters/mysql/schema_statements'
|
2
|
+
|
3
|
+
module ForAlterStatements
|
4
|
+
class << self
|
5
|
+
def included(_)
|
6
|
+
STDERR.puts 'Including for_alter statements'
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def bulk_change_table(table_name, operations) #:nodoc:
|
11
|
+
sqls = operations.flat_map do |command, args|
|
12
|
+
table = args.shift
|
13
|
+
arguments = args
|
14
|
+
|
15
|
+
method = :"#{command}_for_alter"
|
16
|
+
|
17
|
+
raise "Unknown method called : #{method}(#{arguments.inspect})" unless respond_to?(method, true)
|
18
|
+
public_send(method, table, *arguments)
|
19
|
+
end.join(', ')
|
20
|
+
|
21
|
+
execute("ALTER TABLE #{quote_table_name(table_name)} #{sqls}")
|
22
|
+
end
|
23
|
+
|
24
|
+
def change_column_for_alter(table_name, column_name, type, options = {})
|
25
|
+
column = column_for(table_name, column_name)
|
26
|
+
type ||= column.sql_type
|
27
|
+
|
28
|
+
options = {
|
29
|
+
default: column.default,
|
30
|
+
null: column.null,
|
31
|
+
comment: column.comment
|
32
|
+
}.merge(options)
|
33
|
+
|
34
|
+
td = create_table_definition(table_name)
|
35
|
+
cd = td.new_column_definition(column.name, type, options)
|
36
|
+
schema_creation.accept(ActiveRecord::ConnectionAdapters::ChangeColumnDefinition.new(cd, column.name))
|
37
|
+
end
|
38
|
+
|
39
|
+
def rename_column_for_alter(table_name, column_name, new_column_name)
|
40
|
+
column = column_for(table_name, column_name)
|
41
|
+
options = {
|
42
|
+
default: column.default,
|
43
|
+
null: column.null,
|
44
|
+
auto_increment: column.auto_increment?
|
45
|
+
}
|
46
|
+
|
47
|
+
columns_sql = "SHOW COLUMNS FROM #{quote_table_name(table_name)} LIKE #{quote(column_name)}"
|
48
|
+
current_type = exec_query(columns_sql, 'SCHEMA').first['Type']
|
49
|
+
td = create_table_definition(table_name)
|
50
|
+
cd = td.new_column_definition(new_column_name, current_type, options)
|
51
|
+
schema_creation.accept(ActiveRecord::ConnectionAdapters::ChangeColumnDefinition.new(cd, column.name))
|
52
|
+
end
|
53
|
+
|
54
|
+
def add_index_for_alter(table_name, column_name, options = {})
|
55
|
+
index_name, index_type, index_columns, _,
|
56
|
+
index_algorithm, index_using = add_index_options(table_name, column_name, options)
|
57
|
+
|
58
|
+
index_algorithm[0, 0] = ', ' if index_algorithm.present?
|
59
|
+
"ADD #{index_type} INDEX #{quote_column_name(index_name)} #{index_using} (#{index_columns})#{index_algorithm}"
|
60
|
+
end
|
61
|
+
|
62
|
+
def remove_index_for_alter(table_name, options = {})
|
63
|
+
index_name = index_name_for_remove(table_name, options)
|
64
|
+
"DROP INDEX #{quote_column_name(index_name)}"
|
65
|
+
end
|
66
|
+
|
67
|
+
def add_timestamps_for_alter(table_name, options = {})
|
68
|
+
[
|
69
|
+
add_column_for_alter(table_name, :created_at, :datetime, options),
|
70
|
+
add_column_for_alter(table_name, :updated_at, :datetime, options)
|
71
|
+
]
|
72
|
+
end
|
73
|
+
|
74
|
+
def remove_timestamps_for_alter(table_name, _options = {})
|
75
|
+
[remove_column_for_alter(table_name, :updated_at), remove_column_for_alter(table_name, :created_at)]
|
76
|
+
end
|
77
|
+
|
78
|
+
def add_column_for_alter(table_name, column_name, type, options = {})
|
79
|
+
td = create_table_definition(table_name)
|
80
|
+
cd = td.new_column_definition(column_name, type, options)
|
81
|
+
schema_creation.accept(ActiveRecord::ConnectionAdapters::AddColumnDefinition.new(cd))
|
82
|
+
end
|
83
|
+
|
84
|
+
def remove_column_for_alter(_table_name, column_name, _type = nil, _options = {})
|
85
|
+
"DROP COLUMN #{quote_column_name(column_name)}"
|
86
|
+
end
|
87
|
+
|
88
|
+
def remove_columns_for_alter(table_name, *column_names)
|
89
|
+
column_names.map { |column_name| remove_column_for_alter(table_name, column_name) }
|
90
|
+
end
|
91
|
+
end
|
@@ -39,15 +39,31 @@ module ActiveRecord
|
|
39
39
|
|
40
40
|
module ConnectionAdapters
|
41
41
|
class DepartureAdapter < AbstractMysqlAdapter
|
42
|
-
|
43
42
|
class Column < ActiveRecord::ConnectionAdapters::MySQL::Column
|
44
43
|
def adapter
|
45
44
|
DepartureAdapter
|
46
45
|
end
|
47
46
|
end
|
48
47
|
|
48
|
+
class SchemaCreation < ActiveRecord::ConnectionAdapters::MySQL::SchemaCreation
|
49
|
+
def visit_DropForeignKey(name) # rubocop:disable Naming/MethodName
|
50
|
+
fk_name =
|
51
|
+
if name =~ /^__(.+)/
|
52
|
+
Regexp.last_match(1)
|
53
|
+
else
|
54
|
+
"_#{name}"
|
55
|
+
end
|
56
|
+
|
57
|
+
"DROP FOREIGN KEY #{fk_name}"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
49
61
|
extend Forwardable
|
50
62
|
|
63
|
+
unless method_defined?(:change_column_for_alter)
|
64
|
+
include ForAlterStatements
|
65
|
+
end
|
66
|
+
|
51
67
|
ADAPTER_NAME = 'Percona'.freeze
|
52
68
|
|
53
69
|
def_delegators :mysql_adapter, :last_inserted_id, :each_hash, :set_field_encoding
|
@@ -116,11 +132,31 @@ module ActiveRecord
|
|
116
132
|
execute "ALTER TABLE #{quote_table_name(table_name)} DROP INDEX #{quote_column_name(index_name)}"
|
117
133
|
end
|
118
134
|
|
135
|
+
def schema_creation
|
136
|
+
SchemaCreation.new(self)
|
137
|
+
end
|
138
|
+
|
139
|
+
def change_table(table_name, _options = {})
|
140
|
+
recorder = ActiveRecord::Migration::CommandRecorder.new(self)
|
141
|
+
yield update_table_definition(table_name, recorder)
|
142
|
+
bulk_change_table(table_name, recorder.commands)
|
143
|
+
end
|
144
|
+
|
119
145
|
# Returns the MySQL error number from the exception. The
|
120
146
|
# AbstractMysqlAdapter requires it to be implemented
|
121
147
|
def error_number(_exception); end
|
122
148
|
|
123
149
|
def full_version
|
150
|
+
if ActiveRecord::VERSION::MAJOR < 6
|
151
|
+
get_full_version
|
152
|
+
else
|
153
|
+
schema_cache.database_version.full_version_string
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
# This is a method defined in Rails 6.0, and we have no control over the
|
158
|
+
# naming of this method.
|
159
|
+
def get_full_version # rubocop:disable Naming/AccessorMethodName
|
124
160
|
mysql_adapter.raw_connection.server_info[:version]
|
125
161
|
end
|
126
162
|
|
data/lib/departure.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'active_record'
|
2
2
|
require 'active_support/all'
|
3
3
|
|
4
|
+
require 'active_record/connection_adapters/for_alter'
|
5
|
+
|
4
6
|
require 'departure/version'
|
5
7
|
require 'departure/log_sanitizers/password_sanitizer'
|
6
8
|
require 'departure/runner'
|
@@ -11,6 +13,7 @@ require 'departure/logger_factory'
|
|
11
13
|
require 'departure/configuration'
|
12
14
|
require 'departure/errors'
|
13
15
|
require 'departure/command'
|
16
|
+
require 'departure/connection_base'
|
14
17
|
|
15
18
|
require 'departure/railtie' if defined?(Rails)
|
16
19
|
|
@@ -59,7 +62,7 @@ module Departure
|
|
59
62
|
def reconnect_with_percona
|
60
63
|
connection_config = ActiveRecord::Base
|
61
64
|
.connection_config.merge(adapter: 'percona')
|
62
|
-
|
65
|
+
Departure::ConnectionBase.establish_connection(connection_config)
|
63
66
|
end
|
64
67
|
end
|
65
68
|
end
|
@@ -4,7 +4,7 @@ module Departure
|
|
4
4
|
# Represents the '--alter' argument of Percona's pt-online-schema-change
|
5
5
|
# See https://www.percona.com/doc/percona-toolkit/2.0/pt-online-schema-change.html
|
6
6
|
class AlterArgument
|
7
|
-
ALTER_TABLE_REGEX = /\AALTER TABLE
|
7
|
+
ALTER_TABLE_REGEX = /\AALTER TABLE [^\s]*[\n]* /
|
8
8
|
|
9
9
|
attr_reader :table_name
|
10
10
|
|
@@ -17,8 +17,12 @@ module Departure
|
|
17
17
|
|
18
18
|
match = statement.match(ALTER_TABLE_REGEX)
|
19
19
|
raise InvalidAlterStatement unless match
|
20
|
-
|
21
|
-
|
20
|
+
# Separates the ALTER TABLE from the table_name
|
21
|
+
#
|
22
|
+
# Removes the grave marks, if they are there, so we can get the table_name
|
23
|
+
@table_name = String(match)
|
24
|
+
.split(' ')[2]
|
25
|
+
.delete('`')
|
22
26
|
end
|
23
27
|
|
24
28
|
# Returns the '--alter' pt-online-schema-change argument as a string. See
|
@@ -38,6 +42,8 @@ module Departure
|
|
38
42
|
@parsed_statement ||= statement
|
39
43
|
.gsub(ALTER_TABLE_REGEX, '')
|
40
44
|
.gsub('`', '\\\`')
|
45
|
+
.gsub(/\\n/, '')
|
46
|
+
.gsub('"', '\\\"')
|
41
47
|
end
|
42
48
|
end
|
43
49
|
end
|
@@ -15,7 +15,7 @@ module Departure
|
|
15
15
|
#
|
16
16
|
# @return [String]
|
17
17
|
def to_s
|
18
|
-
@to_s ||= "
|
18
|
+
@to_s ||= "#{host_argument} -P #{port} -u #{user} #{password_argument}"
|
19
19
|
end
|
20
20
|
|
21
21
|
# TODO: Doesn't the abstract adapter already handle this somehow?
|
@@ -40,6 +40,17 @@ module Departure
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
+
# Returns the host fragment of the details string, adds ssl options if needed
|
44
|
+
#
|
45
|
+
# @return [String]
|
46
|
+
def host_argument
|
47
|
+
host_string = host
|
48
|
+
if ssl_ca.present?
|
49
|
+
host_string += ";mysql_ssl=1;mysql_ssl_client_ca=#{ssl_ca}"
|
50
|
+
end
|
51
|
+
"-h \"#{host_string}\""
|
52
|
+
end
|
53
|
+
|
43
54
|
private
|
44
55
|
|
45
56
|
attr_reader :connection_data
|
@@ -74,5 +85,12 @@ module Departure
|
|
74
85
|
def port
|
75
86
|
connection_data.fetch(:port, DEFAULT_PORT)
|
76
87
|
end
|
88
|
+
|
89
|
+
# Returns the database' SSL CA certificate.
|
90
|
+
#
|
91
|
+
# @return [String]
|
92
|
+
def ssl_ca
|
93
|
+
connection_data.fetch(:sslca, nil)
|
94
|
+
end
|
77
95
|
end
|
78
96
|
end
|
data/lib/departure/version.rb
CHANGED
data/lib/lhm/column_with_sql.rb
CHANGED
@@ -52,7 +52,7 @@ module Lhm
|
|
52
52
|
#
|
53
53
|
# @return [column_factory]
|
54
54
|
def column
|
55
|
-
cast_type = ActiveRecord::Base.connection.lookup_cast_type
|
55
|
+
cast_type = ActiveRecord::Base.connection.send(:lookup_cast_type, definition)
|
56
56
|
metadata = ActiveRecord::ConnectionAdapters::SqlTypeMetadata.new(
|
57
57
|
type: cast_type.type,
|
58
58
|
sql_type: definition,
|
data/test_database.rb
CHANGED
@@ -6,8 +6,6 @@ require 'active_record/connection_adapters/mysql2_adapter'
|
|
6
6
|
# the tests.
|
7
7
|
#
|
8
8
|
class TestDatabase
|
9
|
-
|
10
|
-
|
11
9
|
# Constructor
|
12
10
|
#
|
13
11
|
# @param config [Hash]
|
@@ -33,10 +31,10 @@ class TestDatabase
|
|
33
31
|
# Creates the ActiveRecord's schema_migrations table required for
|
34
32
|
# migrations to work. Before, it drops the table if it already exists
|
35
33
|
def drop_and_create_schema_migrations_table
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
34
|
+
sql = [
|
35
|
+
"USE #{@database}",
|
36
|
+
'DROP TABLE IF EXISTS schema_migrations',
|
37
|
+
'CREATE TABLE schema_migrations ( version varchar(255) COLLATE utf8_unicode_ci NOT NULL, UNIQUE KEY unique_schema_migrations (version)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci'
|
40
38
|
]
|
41
39
|
|
42
40
|
run_commands(sql)
|
@@ -58,19 +56,17 @@ class TestDatabase
|
|
58
56
|
def drop_and_create_comments_table
|
59
57
|
sql = [
|
60
58
|
"USE #{@database}",
|
61
|
-
|
62
|
-
|
59
|
+
'DROP TABLE IF EXISTS comments',
|
60
|
+
'CREATE TABLE comments ( id bigint(20) NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci'
|
63
61
|
]
|
64
62
|
|
65
63
|
run_commands(sql)
|
66
64
|
end
|
67
65
|
|
68
66
|
def run_commands(sql)
|
69
|
-
conn.execute(
|
70
|
-
sql.each { |str|
|
71
|
-
|
72
|
-
}
|
73
|
-
conn.execute("COMMIT")
|
67
|
+
conn.execute('START TRANSACTION')
|
68
|
+
sql.each { |str| conn.execute(str) }
|
69
|
+
conn.execute('COMMIT')
|
74
70
|
end
|
75
71
|
|
76
72
|
def conn
|
@@ -78,6 +74,7 @@ class TestDatabase
|
|
78
74
|
host: @config['hostname'],
|
79
75
|
username: @config['username'],
|
80
76
|
password: @config['password'],
|
81
|
-
reconnect: true
|
77
|
+
reconnect: true
|
78
|
+
)
|
82
79
|
end
|
83
80
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: departure
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya Zayats
|
@@ -11,39 +11,72 @@ authors:
|
|
11
11
|
- Enrico Stano
|
12
12
|
- Adrian Serafin
|
13
13
|
- Kirk Haines
|
14
|
+
- Guillermo Iguaran
|
14
15
|
autorequire:
|
15
16
|
bindir: bin
|
16
17
|
cert_chain: []
|
17
|
-
date:
|
18
|
+
date: 2020-06-23 00:00:00.000000000 Z
|
18
19
|
dependencies:
|
19
20
|
- !ruby/object:Gem::Dependency
|
20
|
-
name:
|
21
|
+
name: railties
|
21
22
|
requirement: !ruby/object:Gem::Requirement
|
22
23
|
requirements:
|
23
|
-
- - "
|
24
|
+
- - ">="
|
24
25
|
- !ruby/object:Gem::Version
|
25
|
-
version: 5.
|
26
|
+
version: 5.2.0
|
27
|
+
- - "<"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '6.1'
|
26
30
|
type: :runtime
|
27
31
|
prerelease: false
|
28
32
|
version_requirements: !ruby/object:Gem::Requirement
|
29
33
|
requirements:
|
30
|
-
- - "
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 5.2.0
|
37
|
+
- - "<"
|
31
38
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
39
|
+
version: '6.1'
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: activerecord
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 5.2.0
|
47
|
+
- - "<"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '6.1'
|
50
|
+
type: :runtime
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 5.2.0
|
57
|
+
- - "<"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '6.1'
|
33
60
|
- !ruby/object:Gem::Dependency
|
34
61
|
name: mysql2
|
35
62
|
requirement: !ruby/object:Gem::Requirement
|
36
63
|
requirements:
|
37
|
-
- - "
|
64
|
+
- - ">="
|
38
65
|
- !ruby/object:Gem::Version
|
39
66
|
version: 0.4.0
|
67
|
+
- - "<="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.5.3
|
40
70
|
type: :runtime
|
41
71
|
prerelease: false
|
42
72
|
version_requirements: !ruby/object:Gem::Requirement
|
43
73
|
requirements:
|
44
|
-
- - "
|
74
|
+
- - ">="
|
45
75
|
- !ruby/object:Gem::Version
|
46
76
|
version: 0.4.0
|
77
|
+
- - "<="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 0.5.3
|
47
80
|
- !ruby/object:Gem::Dependency
|
48
81
|
name: rake
|
49
82
|
requirement: !ruby/object:Gem::Requirement
|
@@ -131,10 +164,11 @@ description: Execute your ActiveRecord migrations with Percona's pt-online-schem
|
|
131
164
|
email:
|
132
165
|
- ilya.zayats@redbooth.com
|
133
166
|
- pau.perez@redbooth.com
|
134
|
-
-
|
167
|
+
- nflamel@gmail.com
|
135
168
|
- jorge.morante@redbooth.com
|
136
169
|
- adrian@softmad.pl
|
137
170
|
- wyhaines@gmail.com
|
171
|
+
- guilleiguaran@gmail.com
|
138
172
|
executables: []
|
139
173
|
extensions: []
|
140
174
|
extra_rdoc_files: []
|
@@ -159,12 +193,14 @@ files:
|
|
159
193
|
- configuration.rb
|
160
194
|
- departure.gemspec
|
161
195
|
- docker-compose.yml
|
196
|
+
- lib/active_record/connection_adapters/for_alter.rb
|
162
197
|
- lib/active_record/connection_adapters/percona_adapter.rb
|
163
198
|
- lib/departure.rb
|
164
199
|
- lib/departure/alter_argument.rb
|
165
200
|
- lib/departure/cli_generator.rb
|
166
201
|
- lib/departure/command.rb
|
167
202
|
- lib/departure/configuration.rb
|
203
|
+
- lib/departure/connection_base.rb
|
168
204
|
- lib/departure/connection_details.rb
|
169
205
|
- lib/departure/dsn.rb
|
170
206
|
- lib/departure/errors.rb
|
@@ -201,8 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
201
237
|
- !ruby/object:Gem::Version
|
202
238
|
version: '0'
|
203
239
|
requirements: []
|
204
|
-
|
205
|
-
rubygems_version: 2.4.5.2
|
240
|
+
rubygems_version: 3.1.2
|
206
241
|
signing_key:
|
207
242
|
specification_version: 4
|
208
243
|
summary: pt-online-schema-change runner for ActiveRecord migrations
|