departure 6.8.0 → 8.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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +5 -6
  3. data/.rubocop.yml +1 -1
  4. data/Appraisals +8 -10
  5. data/CHANGELOG.md +15 -1
  6. data/Dockerfile +4 -11
  7. data/Gemfile +1 -0
  8. data/Gemfile.lock +91 -75
  9. data/README.md +102 -0
  10. data/Rakefile +1 -0
  11. data/config.yml.erb +8 -4
  12. data/departure.gemspec +4 -4
  13. data/docker-compose.yml +4 -0
  14. data/gemfiles/rails_7_2.gemfile +12 -6
  15. data/gemfiles/rails_7_2.gemfile.lock +96 -59
  16. data/gemfiles/rails_8_0.gemfile +16 -0
  17. data/gemfiles/rails_8_0.gemfile.lock +314 -0
  18. data/gemfiles/rails_8_1.gemfile +15 -0
  19. data/gemfiles/rails_8_1.gemfile.lock +316 -0
  20. data/lib/active_record/connection_adapters/for_alter.rb +4 -17
  21. data/lib/active_record/connection_adapters/rails_8_0_departure_adapter.rb +297 -0
  22. data/lib/active_record/connection_adapters/rails_8_1_departure_adapter.rb +83 -0
  23. data/lib/departure/db_client.rb +52 -0
  24. data/lib/departure/migration.rb +1 -5
  25. data/lib/departure/rails_adapter.rb +99 -39
  26. data/lib/departure/rails_patches/active_record_migrator_with_advisory_lock_patch.rb +2 -2
  27. data/lib/departure/runner.rb +14 -1
  28. data/lib/departure/version.rb +1 -1
  29. data/lib/departure.rb +1 -0
  30. data/lib/lhm/column_with_sql.rb +6 -5
  31. metadata +17 -44
  32. data/gemfiles/rails_6_1.gemfile +0 -10
  33. data/gemfiles/rails_6_1.gemfile.lock +0 -243
  34. data/gemfiles/rails_7_0.gemfile +0 -10
  35. data/gemfiles/rails_7_0.gemfile.lock +0 -242
  36. data/gemfiles/rails_7_1.gemfile +0 -10
  37. data/gemfiles/rails_7_1.gemfile.lock +0 -274
  38. data/lib/active_record/connection_adapters/percona_adapter.rb +0 -186
@@ -1,274 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- departure (6.7.0)
5
- activerecord (>= 6.0.0, < 7.3.0, != 7.0.0)
6
- mysql2 (>= 0.4.0, < 0.6.0)
7
- railties (>= 6.0.0, < 7.3.0, != 7.0.0)
8
-
9
- GEM
10
- remote: https://rubygems.org/
11
- specs:
12
- actioncable (7.1.3)
13
- actionpack (= 7.1.3)
14
- activesupport (= 7.1.3)
15
- nio4r (~> 2.0)
16
- websocket-driver (>= 0.6.1)
17
- zeitwerk (~> 2.6)
18
- actionmailbox (7.1.3)
19
- actionpack (= 7.1.3)
20
- activejob (= 7.1.3)
21
- activerecord (= 7.1.3)
22
- activestorage (= 7.1.3)
23
- activesupport (= 7.1.3)
24
- mail (>= 2.7.1)
25
- net-imap
26
- net-pop
27
- net-smtp
28
- actionmailer (7.1.3)
29
- actionpack (= 7.1.3)
30
- actionview (= 7.1.3)
31
- activejob (= 7.1.3)
32
- activesupport (= 7.1.3)
33
- mail (~> 2.5, >= 2.5.4)
34
- net-imap
35
- net-pop
36
- net-smtp
37
- rails-dom-testing (~> 2.2)
38
- actionpack (7.1.3)
39
- actionview (= 7.1.3)
40
- activesupport (= 7.1.3)
41
- nokogiri (>= 1.8.5)
42
- racc
43
- rack (>= 2.2.4)
44
- rack-session (>= 1.0.1)
45
- rack-test (>= 0.6.3)
46
- rails-dom-testing (~> 2.2)
47
- rails-html-sanitizer (~> 1.6)
48
- actiontext (7.1.3)
49
- actionpack (= 7.1.3)
50
- activerecord (= 7.1.3)
51
- activestorage (= 7.1.3)
52
- activesupport (= 7.1.3)
53
- globalid (>= 0.6.0)
54
- nokogiri (>= 1.8.5)
55
- actionview (7.1.3)
56
- activesupport (= 7.1.3)
57
- builder (~> 3.1)
58
- erubi (~> 1.11)
59
- rails-dom-testing (~> 2.2)
60
- rails-html-sanitizer (~> 1.6)
61
- activejob (7.1.3)
62
- activesupport (= 7.1.3)
63
- globalid (>= 0.3.6)
64
- activemodel (7.1.3)
65
- activesupport (= 7.1.3)
66
- activerecord (7.1.3)
67
- activemodel (= 7.1.3)
68
- activesupport (= 7.1.3)
69
- timeout (>= 0.4.0)
70
- activestorage (7.1.3)
71
- actionpack (= 7.1.3)
72
- activejob (= 7.1.3)
73
- activerecord (= 7.1.3)
74
- activesupport (= 7.1.3)
75
- marcel (~> 1.0)
76
- activesupport (7.1.3)
77
- base64
78
- bigdecimal
79
- concurrent-ruby (~> 1.0, >= 1.0.2)
80
- connection_pool (>= 2.2.5)
81
- drb
82
- i18n (>= 1.6, < 2)
83
- minitest (>= 5.1)
84
- mutex_m
85
- tzinfo (~> 2.0)
86
- appraisal (2.4.1)
87
- bundler
88
- rake
89
- thor (>= 0.14.0)
90
- ast (2.4.2)
91
- base64 (0.2.0)
92
- bigdecimal (3.1.8)
93
- builder (3.3.0)
94
- byebug (11.1.3)
95
- climate_control (0.0.4)
96
- activesupport (>= 3.0)
97
- codeclimate-test-reporter (1.0.9)
98
- simplecov (<= 0.13)
99
- coderay (1.1.3)
100
- concurrent-ruby (1.3.3)
101
- connection_pool (2.4.1)
102
- crass (1.0.6)
103
- date (3.3.4)
104
- diff-lcs (1.5.1)
105
- docile (1.1.5)
106
- drb (2.2.1)
107
- erubi (1.13.0)
108
- globalid (1.2.1)
109
- activesupport (>= 6.1)
110
- i18n (1.14.5)
111
- concurrent-ruby (~> 1.0)
112
- io-console (0.7.2)
113
- irb (1.14.0)
114
- rdoc (>= 4.0.0)
115
- reline (>= 0.4.2)
116
- json (2.7.2)
117
- language_server-protocol (3.17.0.4)
118
- lint_roller (1.1.0)
119
- loofah (2.22.0)
120
- crass (~> 1.0.2)
121
- nokogiri (>= 1.12.0)
122
- mail (2.8.1)
123
- mini_mime (>= 0.1.1)
124
- net-imap
125
- net-pop
126
- net-smtp
127
- marcel (1.0.4)
128
- method_source (1.1.0)
129
- mini_mime (1.1.5)
130
- minitest (5.24.1)
131
- mutex_m (0.2.0)
132
- mysql2 (0.5.6)
133
- net-imap (0.4.12)
134
- date
135
- net-protocol
136
- net-pop (0.1.2)
137
- net-protocol
138
- net-protocol (0.2.2)
139
- timeout
140
- net-smtp (0.5.0)
141
- net-protocol
142
- nio4r (2.7.3)
143
- nokogiri (1.18.3-arm64-darwin)
144
- racc (~> 1.4)
145
- nokogiri (1.18.3-x86_64-linux-gnu)
146
- racc (~> 1.4)
147
- parallel (1.26.3)
148
- parser (3.3.3.0)
149
- ast (~> 2.4.1)
150
- racc
151
- pry (0.14.2)
152
- coderay (~> 1.1)
153
- method_source (~> 1.0)
154
- pry-byebug (3.10.1)
155
- byebug (~> 11.0)
156
- pry (>= 0.13, < 0.15)
157
- psych (5.1.2)
158
- stringio
159
- racc (1.8.0)
160
- rack (3.0.10)
161
- rack-session (2.0.0)
162
- rack (>= 3.0.0)
163
- rack-test (2.1.0)
164
- rack (>= 1.3)
165
- rackup (2.1.0)
166
- rack (>= 3)
167
- webrick (~> 1.8)
168
- rails (7.1.3)
169
- actioncable (= 7.1.3)
170
- actionmailbox (= 7.1.3)
171
- actionmailer (= 7.1.3)
172
- actionpack (= 7.1.3)
173
- actiontext (= 7.1.3)
174
- actionview (= 7.1.3)
175
- activejob (= 7.1.3)
176
- activemodel (= 7.1.3)
177
- activerecord (= 7.1.3)
178
- activestorage (= 7.1.3)
179
- activesupport (= 7.1.3)
180
- bundler (>= 1.15.0)
181
- railties (= 7.1.3)
182
- rails-dom-testing (2.2.0)
183
- activesupport (>= 5.0.0)
184
- minitest
185
- nokogiri (>= 1.6)
186
- rails-html-sanitizer (1.6.0)
187
- loofah (~> 2.21)
188
- nokogiri (~> 1.14)
189
- railties (7.1.3)
190
- actionpack (= 7.1.3)
191
- activesupport (= 7.1.3)
192
- irb
193
- rackup (>= 1.0.0)
194
- rake (>= 12.2)
195
- thor (~> 1.0, >= 1.2.2)
196
- zeitwerk (~> 2.6)
197
- rainbow (3.1.1)
198
- rake (13.2.1)
199
- rdoc (6.7.0)
200
- psych (>= 4.0.0)
201
- regexp_parser (2.10.0)
202
- reline (0.5.9)
203
- io-console (~> 0.5)
204
- rspec (3.13.0)
205
- rspec-core (~> 3.13.0)
206
- rspec-expectations (~> 3.13.0)
207
- rspec-mocks (~> 3.13.0)
208
- rspec-core (3.13.0)
209
- rspec-support (~> 3.13.0)
210
- rspec-expectations (3.13.1)
211
- diff-lcs (>= 1.2.0, < 2.0)
212
- rspec-support (~> 3.13.0)
213
- rspec-its (1.3.0)
214
- rspec-core (>= 3.0.0)
215
- rspec-expectations (>= 3.0.0)
216
- rspec-mocks (3.13.1)
217
- diff-lcs (>= 1.2.0, < 2.0)
218
- rspec-support (~> 3.13.0)
219
- rspec-support (3.13.1)
220
- rubocop (1.74.0)
221
- json (~> 2.3)
222
- language_server-protocol (~> 3.17.0.2)
223
- lint_roller (~> 1.1.0)
224
- parallel (~> 1.10)
225
- parser (>= 3.3.0.2)
226
- rainbow (>= 2.2.2, < 4.0)
227
- regexp_parser (>= 2.9.3, < 3.0)
228
- rubocop-ast (>= 1.38.0, < 2.0)
229
- ruby-progressbar (~> 1.7)
230
- unicode-display_width (>= 2.4.0, < 4.0)
231
- rubocop-ast (1.39.0)
232
- parser (>= 3.3.1.0)
233
- rubocop-performance (1.20.2)
234
- rubocop (>= 1.48.1, < 2.0)
235
- rubocop-ast (>= 1.30.0, < 2.0)
236
- ruby-progressbar (1.13.0)
237
- simplecov (0.13.0)
238
- docile (~> 1.1.0)
239
- json (>= 1.8, < 3)
240
- simplecov-html (~> 0.10.0)
241
- simplecov-html (0.10.2)
242
- stringio (3.1.1)
243
- thor (1.3.1)
244
- timeout (0.4.1)
245
- tzinfo (2.0.6)
246
- concurrent-ruby (~> 1.0)
247
- unicode-display_width (3.1.4)
248
- unicode-emoji (~> 4.0, >= 4.0.4)
249
- unicode-emoji (4.0.4)
250
- webrick (1.8.1)
251
- websocket-driver (0.7.6)
252
- websocket-extensions (>= 0.1.0)
253
- websocket-extensions (0.1.5)
254
- zeitwerk (2.6.16)
255
-
256
- PLATFORMS
257
- arm64-darwin-23
258
- x86_64-linux
259
-
260
- DEPENDENCIES
261
- appraisal (~> 2.4.1)
262
- climate_control (~> 0.0.3)
263
- codeclimate-test-reporter (~> 1.0.3)
264
- departure!
265
- pry-byebug
266
- rails (= 7.1.3)
267
- rake (>= 10.0)
268
- rspec (~> 3.4, >= 3.4.0)
269
- rspec-its (~> 1.2)
270
- rubocop (~> 1.74.0)
271
- rubocop-performance (~> 1.20.2)
272
-
273
- BUNDLED WITH
274
- 2.4.22
@@ -1,186 +0,0 @@
1
- require 'active_record/connection_adapters/abstract_mysql_adapter'
2
- require 'active_record/connection_adapters/statement_pool'
3
- require 'active_record/connection_adapters/mysql2_adapter'
4
- require 'active_record/connection_adapters/patch_connection_handling'
5
- require 'active_support/core_ext/string/filters'
6
- require 'departure'
7
- require 'forwardable'
8
-
9
- module ActiveRecord
10
- module ConnectionAdapters
11
- class DepartureAdapter < AbstractMysqlAdapter
12
- TYPE_MAP = Type::TypeMap.new.tap { |m| initialize_type_map(m) } if defined?(initialize_type_map)
13
-
14
- class Column < ActiveRecord::ConnectionAdapters::MySQL::Column
15
- def adapter
16
- DepartureAdapter
17
- end
18
- end
19
-
20
- class SchemaCreation < ActiveRecord::ConnectionAdapters::MySQL::SchemaCreation
21
- def visit_DropForeignKey(name) # rubocop:disable Style/MethodName
22
- fk_name =
23
- if name =~ /^__(.+)/
24
- Regexp.last_match(1)
25
- else
26
- "_#{name}"
27
- end
28
-
29
- "DROP FOREIGN KEY #{fk_name}"
30
- end
31
- end
32
-
33
- extend Forwardable
34
-
35
- unless method_defined?(:change_column_for_alter)
36
- include ForAlterStatements
37
- end
38
-
39
- ADAPTER_NAME = 'Percona'.freeze
40
-
41
- def_delegators :mysql_adapter, :each_hash, :set_field_encoding
42
-
43
- def initialize(connection, _logger, connection_options, _config)
44
- @mysql_adapter = connection_options[:mysql_adapter]
45
- super
46
- @prepared_statements = false
47
- end
48
-
49
- def write_query?(sql) # :nodoc:
50
- !ActiveRecord::ConnectionAdapters::AbstractAdapter.build_read_query_regexp(
51
- :desc, :describe, :set, :show, :use
52
- ).match?(sql)
53
- end
54
-
55
- def exec_delete(sql, name, binds)
56
- execute(to_sql(sql, binds), name)
57
- mysql_adapter.raw_connection.affected_rows
58
- end
59
- alias exec_update exec_delete
60
-
61
- def exec_insert(sql, name, binds, pk = nil, sequence_name = nil, returning: nil) # rubocop:disable Lint/UnusedMethodArgument, Metrics/LineLength, Metrics/ParameterLists
62
- execute(to_sql(sql, binds), name)
63
- end
64
-
65
- def internal_exec_query(sql, name = 'SQL', _binds = [], **_kwargs) # :nodoc:
66
- result = execute(sql, name)
67
- fields = result.fields if defined?(result.fields)
68
- ActiveRecord::Result.new(fields, result.to_a)
69
- end
70
- alias exec_query internal_exec_query
71
-
72
- # Executes a SELECT query and returns an array of rows. Each row is an
73
- # array of field values.
74
-
75
- def select_rows(arel, name = nil, binds = [])
76
- select_all(arel, name, binds).rows
77
- end
78
-
79
- # Executes a SELECT query and returns an array of record hashes with the
80
- # column names as keys and column values as values.
81
- def select(sql, name = nil, binds = [], **kwargs)
82
- exec_query(sql, name, binds, **kwargs)
83
- end
84
-
85
- # Returns true, as this adapter supports migrations
86
- def supports_migrations?
87
- true
88
- end
89
-
90
- # rubocop:disable Metrics/ParameterLists
91
- def new_column(field, default, type_metadata, null, table_name, default_function, collation, comment)
92
- Column.new(field, default, type_metadata, null, table_name, default_function, collation, comment)
93
- end
94
- # rubocop:enable Metrics/ParameterLists
95
-
96
- # Adds a new index to the table
97
- #
98
- # @param table_name [String, Symbol]
99
- # @param column_name [String, Symbol]
100
- # @param options [Hash] optional
101
- def add_index(table_name, column_name, options = {})
102
- if ActiveRecord::VERSION::STRING >= '6.1'
103
- index_definition, = add_index_options(table_name, column_name, **options)
104
- execute <<-SQL.squish
105
- ALTER TABLE #{quote_table_name(index_definition.table)}
106
- ADD #{schema_creation.accept(index_definition)}
107
- SQL
108
- else
109
- index_name, index_type, index_columns, index_options = add_index_options(table_name, column_name, **options)
110
- execute <<-SQL.squish
111
- ALTER TABLE #{quote_table_name(table_name)}
112
- ADD #{index_type} INDEX
113
- #{quote_column_name(index_name)} (#{index_columns})#{index_options}
114
- SQL
115
- end
116
- end
117
-
118
- # Remove the given index from the table.
119
- #
120
- # @param table_name [String, Symbol]
121
- # @param options [Hash] optional
122
- def remove_index(table_name, column_name = nil, **options)
123
- if ActiveRecord::VERSION::STRING >= '6.1'
124
- return if options[:if_exists] && !index_exists?(table_name, column_name, **options)
125
- index_name = index_name_for_remove(table_name, column_name, options)
126
- else
127
- index_name = index_name_for_remove(table_name, options)
128
- end
129
-
130
- execute "ALTER TABLE #{quote_table_name(table_name)} DROP INDEX #{quote_column_name(index_name)}"
131
- end
132
-
133
- def schema_creation
134
- SchemaCreation.new(self)
135
- end
136
-
137
- def change_table(table_name, _options = {})
138
- recorder = ActiveRecord::Migration::CommandRecorder.new(self)
139
- yield update_table_definition(table_name, recorder)
140
- bulk_change_table(table_name, recorder.commands)
141
- end
142
-
143
- # Returns the MySQL error number from the exception. The
144
- # AbstractMysqlAdapter requires it to be implemented
145
- def error_number(_exception); end
146
-
147
- def full_version
148
- if ActiveRecord::VERSION::MAJOR < 6
149
- get_full_version
150
- else
151
- schema_cache.database_version.full_version_string
152
- end
153
- end
154
-
155
- # This is a method defined in Rails 6.0, and we have no control over the
156
- # naming of this method.
157
- def get_full_version # rubocop:disable Style/AccessorMethodName
158
- mysql_adapter.raw_connection.server_info[:version]
159
- end
160
-
161
- def last_inserted_id(result)
162
- mysql_adapter.send(:last_inserted_id, result)
163
- end
164
-
165
- private
166
-
167
- attr_reader :mysql_adapter
168
-
169
- if ActiveRecord.version >= Gem::Version.create('7.1.0')
170
- def raw_execute(sql, name, async: false, allow_retry: false, materialize_transactions: true)
171
- log(sql, name, async: async) do
172
- with_raw_connection(allow_retry: allow_retry, materialize_transactions: materialize_transactions) do |conn|
173
- sync_timezone_changes(conn)
174
- result = conn.query(sql)
175
- verified!
176
- handle_warnings(sql)
177
- result
178
- end
179
- end
180
- end
181
- end
182
-
183
- def reconnect; end
184
- end
185
- end
186
- end