departure 3.0.1 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4128e93b7f92a2b1b74274f3f96936e37463c565
4
- data.tar.gz: f01ddfd8e230f37bbd3d1dfaaca7f7dd235d4fca
3
+ metadata.gz: 6212b46cc9534ddacaefd8341432e124ccce6247
4
+ data.tar.gz: 4f99581bf9f9657ff07adf9684dc93d40b9dfa8c
5
5
  SHA512:
6
- metadata.gz: 68807558488c5cf6dd6ecdcb6b0ad83966a1e75d5994ab8b650aeed12e3784c20035cf6ce750af7a430f2263573d2cde049b627aa6fe125793bd39c6ebad5b54
7
- data.tar.gz: 0ea99d8fa590efee5874d0cefe8b8ed78d2d4bb8f1c03ca774a1f32d873d7ea2eac3934767ef983982dcb36fef2d2d1a7e0469e677dffa4fe87196aeb2537026
6
+ metadata.gz: 85c386d3d73919fe7e61d805835d5ddd8478fc8f204be09bd563151d67f1469424c7a89e40bdee579da483687f9602d071f80dd3bf9cdd547c78d2e80a91e325
7
+ data.tar.gz: aeef6570099eee655fc5eb7cd4b9dda7c0f7f4c482d575b83700ad8cbdbe63a1a914e173de1dc68467aa2b84fd2d3ba61d7608ed8a6ea03d422451a798e297c7
@@ -12,29 +12,31 @@ Please follow the format in [Keep a Changelog](http://keepachangelog.com/)
12
12
  ### Removed
13
13
  ### Fixed
14
14
 
15
- ## [3.0.1] - 2017-05-11
15
+ ## [4.0.0] - 2017-06-12
16
16
 
17
17
  ### Added
18
+ ### Changed
18
19
 
19
- - Allow running on other than default MySQL port
20
+ - Rename the gem from percona_migrator to departure.
20
21
 
21
- ### Changed
22
22
  ### Deprecated
23
23
  ### Removed
24
- ### Fixed
25
24
 
26
- - Handle special characters in connection's password
27
- - `rename_table` and `rename_index` migration methods
25
+ - Percona_migrator's deprecation warnings when installing and running the gem.
26
+
27
+ ### Fixed
28
28
 
29
- ## [3.0.0] - 2017-05-02
29
+ ## [3.0.0] - 2016-04-07
30
30
 
31
31
  ### Added
32
32
 
33
+ - Support for ActiveRecord 4.2.x
34
+ - Support for Mysql2 4.x
33
35
  - Allow passing any `pt-online-schema-change`'s arguments through the
34
36
  `PERCONA_ARGS` env var when executing a migration with `rake db:migrate:up`
35
37
  or `db:migrate:down`.
36
- - Filter MySQL's password from logs.
37
- - Allow setting global percona arguments via gem configuration.
38
+ - Allow setting global percona arguments via gem configuration
39
+ - Filter MySQL's password from logs
38
40
 
39
41
  ### Changed
40
42
 
@@ -42,13 +44,6 @@ Please follow the format in [Keep a Changelog](http://keepachangelog.com/)
42
44
  So far, this was purposely set to `none`. To keep this same behaviour
43
45
  provide the `PERCONA_ARGS=--recursion-method=none` env var when running the
44
46
  migration.
45
- - Rename the gem from percona_migrator to departure.
46
-
47
- ### Removed
48
-
49
- - Percona_migrator's deprecation warnings when installing and running the gem.
50
-
51
- ### Fixed
52
47
 
53
48
  ## [1.0.0] - 2016-11-30
54
49
 
data/README.md CHANGED
@@ -26,6 +26,21 @@ Toolkit](https://www.percona.com/doc/percona-toolkit/2.0/pt-online-schema-change
26
26
 
27
27
  `brew install percona-toolkit`
28
28
 
29
+ If when running a migration you see an error like:
30
+
31
+ ```
32
+ PerconaMigrator::Error: Cannot connect to MySQL: Cannot connect to MySQL because
33
+ the Perl DBI module is not installed or not found.
34
+ ```
35
+
36
+ You also need to install the DBI and DBD::MySQL modules from `cpan`.
37
+
38
+ ```
39
+ $ sudo cpan
40
+ cpan> install DBI
41
+ cpan> install DBD::mysql
42
+ ```
43
+
29
44
  ### Linux
30
45
 
31
46
  #### Ubuntu/Debian based
@@ -97,7 +112,7 @@ You can specify any `pt-online-schema-change` arguments in global gem configurat
97
112
  using `global_percona_args` option.
98
113
 
99
114
  ```ruby
100
- PerconaMigrator.configure do |config|
115
+ Departure.configure do |config|
101
116
  config.global_percona_args = '--chunk-time=1 --critical-load=55'
102
117
  end
103
118
  ```
@@ -123,7 +138,7 @@ again in your next migration.
123
138
  You can override any of the default values from an initializer:
124
139
 
125
140
  ```ruby
126
- PerconaMigrator.configure do |config|
141
+ Departure.configure do |config|
127
142
  config.tmp_path = '/tmp/'
128
143
  end
129
144
  ```
@@ -135,20 +150,20 @@ It's strongly recommended to name it after this gems name, such as
135
150
 
136
151
  When booting your Rails app, Departure extends the
137
152
  `ActiveRecord::Migration#migrate` method to reset the connection and reestablish
138
- it using the `PerconaAdapter` instead of the one you defined in your
153
+ it using the `DepartureAdapter` instead of the one you defined in your
139
154
  `config/database.yml`.
140
155
 
141
156
  Then, when any migration DSL methods such as `add_column` or `create_table` are
142
157
  executed, they all go to the
143
- [PerconaAdapter](https://github.com/redbooth/departure/blob/master/lib/active_record/connection_adapters/percona_adapter.rb).
158
+ [DepartureAdapter](https://github.com/redbooth/departure/blob/master/lib/active_record/connection_adapters/departure_adapter.rb).
144
159
  There, the methods that require `ALTER TABLE` SQL statements, like `add_column`,
145
160
  are overriden to get executed with
146
- [PerconaMigrator::Runner](https://github.com/redbooth/departure/blob/master/lib/departure/runner.rb),
161
+ [Departure::Runner](https://github.com/redbooth/departure/blob/master/lib/departure/runner.rb),
147
162
  which deals with the `pt-online-schema-change` binary. All the others, like
148
163
  `create_table`, are delegated to the ActiveRecord's built in Mysql2Adapter and
149
164
  so they follow the regular path.
150
165
 
151
- [PerconaMigrator::Runner](https://github.com/redbooth/departure/blob/master/lib/departure/runner.rb)
166
+ [Departure::Runner](https://github.com/redbooth/departure/blob/master/lib/departure/runner.rb)
152
167
  spawns a new process that runs the `pt-online-schema-change` binary present in
153
168
  the system, with the apropriate arguments for the generated SQL.
154
169
 
@@ -1,4 +1,4 @@
1
- # Releasing Departure
1
+ # Releasing Percona Migrator
2
2
 
3
3
  All releases come from the master branch. All other branches won't be maintained
4
4
  and will receive bug fix releases only.
@@ -7,7 +7,7 @@ In order to give support to a new major Rails version, we'll branch off of
7
7
  master, name it following the Rails repo convention, such as `v4.2`, and
8
8
  we'll keep it open for bug fixes.
9
9
 
10
- 1. Update `lib/departure/version.rb` accordingly
10
+ 1. Update `lib/percona_migrator/version.rb` accordingly
11
11
  2. Review the `CHANGELOG.md` and add a new section following the format
12
12
  `[version] - YYYY-MM-DD`. We conform to the guidelines of
13
13
  http://keepachangelog.com/
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_runtime_dependency 'rails', '~> 4.1.0'
22
- spec.add_runtime_dependency 'mysql2', '0.3.20'
21
+ spec.add_runtime_dependency 'rails', '~> 4.2.0'
22
+ spec.add_runtime_dependency 'mysql2', '~> 0.4.0'
23
23
 
24
24
  spec.add_development_dependency 'bundler', '~> 1.10'
25
25
  spec.add_development_dependency 'rake', '~> 10.0'
@@ -51,12 +51,11 @@ module ActiveRecord
51
51
 
52
52
  ADAPTER_NAME = 'Percona'.freeze
53
53
 
54
- def_delegators :mysql_adapter, :last_inserted_id, :each_hash,
55
- :set_field_encoding, :full_version
54
+ def_delegators :mysql_adapter, :last_inserted_id, :each_hash, :set_field_encoding
56
55
 
57
56
  def initialize(connection, _logger, connection_options, _config)
58
57
  super
59
- @visitor = BindSubstitution.new(self)
58
+ @prepared_statements = false
60
59
  @mysql_adapter = connection_options[:mysql_adapter]
61
60
  end
62
61
 
@@ -92,8 +91,8 @@ module ActiveRecord
92
91
  true
93
92
  end
94
93
 
95
- def new_column(field, default, type, null, collation, extra = "")
96
- Column.new(field, default, type, null, collation, extra)
94
+ def new_column(field, default, cast_type, sql_type = nil, null = true, collation = '', extra = '')
95
+ Column.new(field, default, cast_type, sql_type, null, collation, strict_mode?, extra)
97
96
  end
98
97
 
99
98
  # Adds a new index to the table
@@ -120,6 +119,10 @@ module ActiveRecord
120
119
  def error_number(_exception)
121
120
  end
122
121
 
122
+ def full_version
123
+ mysql_adapter.raw_connection.server_info[:version]
124
+ end
125
+
123
126
  private
124
127
 
125
128
  attr_reader :mysql_adapter
@@ -18,7 +18,6 @@ module Departure
18
18
  [
19
19
  Option.new('execute'),
20
20
  Option.new('statistics'),
21
- Option.new('recursion-method', 'none'),
22
21
  Option.new('alter-foreign-keys-method', 'auto'),
23
22
  Option.new('no-check-alter')
24
23
  ]
@@ -2,7 +2,6 @@ module Departure
2
2
  # Holds the parameters of the DB connection and formats them to string
3
3
  class ConnectionDetails
4
4
 
5
- DEFAULT_PORT = 3306
6
5
  # Constructor
7
6
  #
8
7
  # @param [Hash] connection parametes as used in #establish_conneciton
@@ -15,7 +14,7 @@ module Departure
15
14
  #
16
15
  # @return [String]
17
16
  def to_s
18
- @to_s ||= "-h #{host} -P #{port} -u #{user} #{password_argument}"
17
+ @to_s ||= "-h #{host} -u #{user} #{password_argument}"
19
18
  end
20
19
 
21
20
  # TODO: Doesn't the abstract adapter already handle this somehow?
@@ -34,7 +33,7 @@ module Departure
34
33
  # @return [String]
35
34
  def password_argument
36
35
  if password.present?
37
- %Q[--password "#{password}" ]
36
+ "-p #{password}"
38
37
  else
39
38
  ''
40
39
  end
@@ -67,12 +66,5 @@ module Departure
67
66
  def password
68
67
  ENV.fetch('PERCONA_DB_PASSWORD', connection_data[:password])
69
68
  end
70
-
71
- # Returns the database's port.
72
- #
73
- # @return [String]
74
- def port
75
- connection_data.fetch(:port, DEFAULT_PORT)
76
- end
77
69
  end
78
70
  end
@@ -1,3 +1,3 @@
1
1
  module Departure
2
- VERSION = '3.0.1'.freeze
2
+ VERSION = '4.0.0'.freeze
3
3
  end
@@ -2,8 +2,8 @@ require 'forwardable'
2
2
 
3
3
  module Lhm
4
4
 
5
- # Abstracts the details of a table column definition when specified with a
6
- # MySQL column definition string
5
+ # Abstracts the details of a table column definition when specified with a MySQL
6
+ # column definition string
7
7
  class ColumnWithSql
8
8
  extend Forwardable
9
9
 
@@ -53,9 +53,11 @@ module Lhm
53
53
  #
54
54
  # @return [column_factory]
55
55
  def column
56
+ cast_type = ActiveRecord::Base.connection.lookup_cast_type(definition)
56
57
  @column ||= self.class.column_factory.new(
57
58
  name,
58
59
  default_value,
60
+ cast_type,
59
61
  definition,
60
62
  null_value
61
63
  )
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: 3.0.1
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Zayats
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2017-05-11 00:00:00.000000000 Z
16
+ date: 2017-06-12 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: rails
@@ -21,28 +21,28 @@ dependencies:
21
21
  requirements:
22
22
  - - "~>"
23
23
  - !ruby/object:Gem::Version
24
- version: 4.1.0
24
+ version: 4.2.0
25
25
  type: :runtime
26
26
  prerelease: false
27
27
  version_requirements: !ruby/object:Gem::Requirement
28
28
  requirements:
29
29
  - - "~>"
30
30
  - !ruby/object:Gem::Version
31
- version: 4.1.0
31
+ version: 4.2.0
32
32
  - !ruby/object:Gem::Dependency
33
33
  name: mysql2
34
34
  requirement: !ruby/object:Gem::Requirement
35
35
  requirements:
36
- - - '='
36
+ - - "~>"
37
37
  - !ruby/object:Gem::Version
38
- version: 0.3.20
38
+ version: 0.4.0
39
39
  type: :runtime
40
40
  prerelease: false
41
41
  version_requirements: !ruby/object:Gem::Requirement
42
42
  requirements:
43
- - - '='
43
+ - - "~>"
44
44
  - !ruby/object:Gem::Version
45
- version: 0.3.20
45
+ version: 0.4.0
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: bundler
48
48
  requirement: !ruby/object:Gem::Requirement