data_migrate 11.1.0 → 11.3.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 (59) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +11 -0
  3. data/README.md +13 -18
  4. data/lib/data_migrate/config.rb +2 -1
  5. data/lib/data_migrate/data_migrator.rb +0 -1
  6. data/lib/data_migrate/data_schema_migration.rb +2 -2
  7. data/lib/data_migrate/database_tasks.rb +14 -4
  8. data/lib/data_migrate/rails_helper.rb +1 -0
  9. data/lib/data_migrate/version.rb +1 -1
  10. metadata +5 -54
  11. data/.github/workflows/build.yml +0 -39
  12. data/.github/workflows/gempush.yml +0 -28
  13. data/.gitignore +0 -12
  14. data/.hound.yml +0 -4
  15. data/.overcommit.yml +0 -21
  16. data/.rbenv-gemsets +0 -2
  17. data/.rspec +0 -3
  18. data/.rubocop.yml +0 -2
  19. data/.ruby-style.yml +0 -1061
  20. data/Appraisals +0 -19
  21. data/Gemfile +0 -3
  22. data/Gemfile.lock +0 -192
  23. data/Rakefile +0 -2
  24. data/data_migrate.gemspec +0 -41
  25. data/gemfiles/rails_6.1.gemfile +0 -7
  26. data/gemfiles/rails_6.1.gemfile.lock +0 -237
  27. data/gemfiles/rails_7.0.gemfile +0 -7
  28. data/gemfiles/rails_7.0.gemfile.lock +0 -238
  29. data/gemfiles/rails_7.1.gemfile +0 -7
  30. data/gemfiles/rails_7.1.gemfile.lock +0 -277
  31. data/gemfiles/rails_7.2.gemfile +0 -7
  32. data/gemfiles/rails_7.2.gemfile.lock +0 -274
  33. data/gemfiles/rails_8.0.gemfile +0 -7
  34. data/gemfiles/rails_8.0.gemfile.lock +0 -268
  35. data/screenshot.png +0 -0
  36. data/spec/data_migrate/config_spec.rb +0 -69
  37. data/spec/data_migrate/data_migrator_spec.rb +0 -84
  38. data/spec/data_migrate/data_schema_migration_spec.rb +0 -33
  39. data/spec/data_migrate/data_spec.rb +0 -74
  40. data/spec/data_migrate/database_tasks_spec.rb +0 -214
  41. data/spec/data_migrate/migration.rb +0 -17
  42. data/spec/data_migrate/migration_context_spec.rb +0 -117
  43. data/spec/data_migrate/schema_dumper_spec.rb +0 -36
  44. data/spec/data_migrate/schema_migration_spec.rb +0 -104
  45. data/spec/data_migrate/status_service_spec.rb +0 -76
  46. data/spec/data_migrate/tasks/data_migrate_tasks_spec.rb +0 -129
  47. data/spec/db/data/20091231235959_some_name.rb +0 -9
  48. data/spec/db/data/20171231235959_super_update.rb +0 -9
  49. data/spec/db/data/20181128000207_excluded_file.rb.other_ext +0 -1
  50. data/spec/db/data/partial_schema/data_schema.rb +0 -1
  51. data/spec/db/data/partial_schema/test_data_schema.rb +0 -1
  52. data/spec/db/data/schema/data_schema.rb +0 -1
  53. data/spec/db/data/schema/test_data_schema.rb +0 -1
  54. data/spec/db/data_two/20241231235959_data_two_update.rb +0 -9
  55. data/spec/db/migrate/20131111111111_late_migration.rb +0 -9
  56. data/spec/db/migrate/20202020202011_db_migration.rb +0 -9
  57. data/spec/generators/data_migration/data_migration_generator_spec.rb +0 -101
  58. data/spec/spec_helper.rb +0 -28
  59. data/tasks/.gitkeep +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 93b03e47ca0a194f18a72fdb0cc47a54de82688858aa6660827ef7f68644ef8d
4
- data.tar.gz: 4aa2328b5e432edb4b445fa46efe0f2871e5eb47acee15a02c2a19bc4505404b
3
+ metadata.gz: 20f45c0a409f5eea659d56b8118d9625e3358cdd9d199978b56359d3416abe64
4
+ data.tar.gz: f553fd264b97b71671556ece98e9c79830223e960e7f41a46e383587a7b728c3
5
5
  SHA512:
6
- metadata.gz: 975645eca490e58faa6895abd76888876f2fa5d90487272d95441c6f887d75799db561c1a5773b53dd3f0d4fe9ffe3487beb964eab138766243cde3162dd0284
7
- data.tar.gz: d6aa8d28e0225ab194440f51b5c66787a363e4021c5291215ba406f7c410dd13ae898cdc3a19bb43908c20de6c0801c7bc3a51dcc78b8df7ccf69178d55568eb
6
+ metadata.gz: 8ac579c9ca5323c12e413f4c2ad228f9f36cbeb7d84624ff6fa24160f350b5e91f3ca7a8f18e469ce8e25dd4390a9d76316f40257dd9ef5bf4324c60309dd55f
7
+ data.tar.gz: f2fe12d32734ba839ce736d6634d2e794aad151b2719ff6e4a9bf1c9a05ccfdc4ab2a2de6bed8636a9423e89d6dddf62442ccf2f4c91ede15cf66736f36ff64f
data/Changelog.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ # 11.3.0
4
+ - Make table_name configurable https://github.com/ilyakatz/data-migrate/pull/361
5
+ - Use lease_connection over deprecated connection for rails 8 https://github.com/ilyakatz/data-migrate/pull/353
6
+ - Add Ruby 3.4 to CI matrix
7
+
8
+ # 11.2.0
9
+ - Remove committed Gemfile.lock, reduce bundled file list when running `gem install` https://github.com/ilyakatz/data-migrate/pull/351
10
+ - [Bump actionpack from 7.1.3.4 to 7.1.4.1](https://github.com/ilyakatz/data-migrate/pull/348)
11
+ - [Bump rexml from 3.3.6 to 3.3.9](https://github.com/ilyakatz/data-migrate/pull/349)
12
+ - Fix db_config_with_versions arity change and backport https://github.com/ilyakatz/data-migrate/pull/337
13
+
3
14
  # 11.1.0
4
15
  - Allow multiple data migration paths https://github.com/ilyakatz/data-migrate/pull/331
5
16
  - Fix db:prepare:with_data task on [Rails 7.2](https://github.com/ilyakatz/data-migrate/pull/339)
data/README.md CHANGED
@@ -36,7 +36,7 @@ table to track all migrations.
36
36
 
37
37
  ## Rails Support
38
38
 
39
- Support Rails 6.1 through 7.2
39
+ Support Rails 6.1 through 8.0
40
40
 
41
41
  For **Rails 6.0** support, please use gem version `9.1.x`:
42
42
 
@@ -115,6 +115,7 @@ You can override this setting in `config/initializers/data_migrate.rb`
115
115
 
116
116
  ```ruby
117
117
  DataMigrate.configure do |config|
118
+ config.data_migrations_table_name = 'my_migrations_database_name'
118
119
  config.data_migrations_path = 'db/awesomepath/'
119
120
  config.data_template_path = Rails.root.join("lib", "awesomepath", "custom_data_migration.rb")
120
121
  config.db_configuration = {
@@ -144,19 +145,12 @@ From now on capistrano will run `rake db:migrate:with_data` in every deploy.
144
145
  ## Rails Engines support
145
146
 
146
147
  This gem also has a initial support for adding data migrations inside Rails engines.
147
- Inside the Engine's class initializer (the one that inherits from `Rails::Engine`, usually inside `engines/ENGINE_NAME/lib/engine.rb`) you need to add something like this:
148
-
148
+ Just add your engines directory pattern to data_migrations initializer, for example
149
+ in the case your engines are located in `engines` folder you can set it up like this:
149
150
 
150
151
  ```ruby
151
- module EngineName
152
- class Engine < ::Rails::Engine
153
- initializer :engine_name do |app|
154
- ::DataMigrate.configure do |data_migrate|
155
- default_path = ::DataMigrate::Config.new.data_migrations_path
156
- data_migrate.data_migrations_path = [default_path, root.join('db', 'data')]
157
- end
158
- end
159
- end
152
+ DataMigrate.configure do |config|
153
+ config.data_migrations_path = ['db/data'] + Dir['engines/**/db/data']
160
154
  end
161
155
  ```
162
156
 
@@ -169,20 +163,21 @@ Then, in the Engine's `db/data` folder, you can add data migrations and run them
169
163
  Run tests for a specific version of Rails
170
164
 
171
165
  ```
172
-
173
166
  bundle exec appraisal rails-6.1 rspec
174
167
  bundle exec appraisal rails-7.0 rspec
175
168
  bundle exec appraisal rails-7.1 rspec
176
169
  bundle exec appraisal rails-7.2 rspec
170
+ bundle exec appraisal rails-8.0 rspec
177
171
  ```
178
172
 
179
173
  ## Releasing new version
180
174
 
181
- 1. Create a new tag, eg `git tag 9.4.1`
182
- 1. Go to https://github.com/ilyakatz/data-migrate/tags
183
- 1. Click "Create release" under 9.4.1
184
- 1. CLick "Generate release notes"
185
- 1. Click "Publish release"
175
+ 1. Update version.rb file, run `bundle exec appraisal` to update the version in corresponding gemfile.lock
176
+ 2. Create a new tag, eg `git tag 9.4.1`
177
+ 3. Go to https://github.com/ilyakatz/data-migrate/tags
178
+ 4. Click "Create release" under 9.4.1
179
+ 5. CLick "Generate release notes"
180
+ 6. Click "Publish release"
186
181
 
187
182
  ## Thanks
188
183
 
@@ -12,11 +12,12 @@ module DataMigrate
12
12
  end
13
13
 
14
14
  class Config
15
- attr_accessor :data_migrations_path, :data_template_path, :db_configuration, :spec_name
15
+ attr_accessor :data_migrations_table_name, :data_migrations_path, :data_template_path, :db_configuration, :spec_name
16
16
 
17
17
  DEFAULT_DATA_TEMPLATE_PATH = "data_migration.rb"
18
18
 
19
19
  def initialize
20
+ @data_migrations_table_name = "data_migrations"
20
21
  @data_migrations_path = "db/data/"
21
22
  @data_template_path = DEFAULT_DATA_TEMPLATE_PATH
22
23
  @db_configuration = nil
@@ -48,7 +48,6 @@ module DataMigrate
48
48
 
49
49
  # TODO: this was added to be backward compatible, need to re-evaluate
50
50
  def migrations(_migrations_paths)
51
- #DataMigrate::MigrationContext.new(migrations_paths).migrations
52
51
  DataMigrate::MigrationContext.new(_migrations_paths).migrations
53
52
  end
54
53
 
@@ -4,7 +4,7 @@ module DataMigrate
4
4
  # So we only load the appropriate methods depending on Rails version.
5
5
  if DataMigrate::RailsHelper.rails_version_equal_to_or_higher_than_7_1
6
6
  def table_name
7
- ActiveRecord::Base.table_name_prefix + 'data_migrations' + ActiveRecord::Base.table_name_suffix
7
+ ActiveRecord::Base.table_name_prefix + DataMigrate.config.data_migrations_table_name + ActiveRecord::Base.table_name_suffix
8
8
  end
9
9
 
10
10
  def primary_key
@@ -13,7 +13,7 @@ module DataMigrate
13
13
  else
14
14
  class << self
15
15
  def table_name
16
- ActiveRecord::Base.table_name_prefix + 'data_migrations' + ActiveRecord::Base.table_name_suffix
16
+ ActiveRecord::Base.table_name_prefix + DataMigrate.config.data_migrations_table_name + ActiveRecord::Base.table_name_suffix
17
17
  end
18
18
 
19
19
  def primary_key
@@ -9,6 +9,13 @@ module DataMigrate
9
9
  extend ActiveRecord::Tasks::DatabaseTasks
10
10
  extend self
11
11
 
12
+ if respond_to?(:register_task)
13
+ register_task(/mysql/, "ActiveRecord::Tasks::MySQLDatabaseTasks")
14
+ register_task(/trilogy/, "ActiveRecord::Tasks::MySQLDatabaseTasks")
15
+ register_task(/postgresql/, "ActiveRecord::Tasks::PostgreSQLDatabaseTasks")
16
+ register_task(/sqlite/, "ActiveRecord::Tasks::SQLiteDatabaseTasks")
17
+ end
18
+
12
19
  # These method are only introduced in Rails 7.1
13
20
  unless respond_to?(:with_temporary_pool_for_each)
14
21
  def with_temporary_pool_for_each(env: ActiveRecord::Tasks::DatabaseTasks.env, name: nil, &block) # :nodoc:
@@ -99,7 +106,7 @@ module DataMigrate
99
106
  end
100
107
 
101
108
  def sort_migrations(*migrations)
102
- migrations.flatten.sort { |a, b| sort_string(a) <=> sort_string(b) }
109
+ migrations.flatten.sort { |a, b| sort_string(a) <=> sort_string(b) }
103
110
  end
104
111
 
105
112
  def sort_string migration
@@ -159,7 +166,7 @@ module DataMigrate
159
166
  data_migrator = DataMigrate::RailsHelper.data_migrator(:up, data_migrations)
160
167
  sort_migrations(
161
168
  data_migrator.pending_migrations.map { |m| { version: m.version, name: m.name, kind: :data } }
162
- )
169
+ )
163
170
  end
164
171
 
165
172
  def pending_schema_migrations
@@ -179,7 +186,9 @@ module DataMigrate
179
186
 
180
187
  ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
181
188
 
182
- schema_mapped_versions = if DataMigrate::RailsHelper.rails_version_equal_to_or_higher_than_7_1
189
+ # 7.2 removes the param for db_configs_with_versions in https://github.com/rails/rails/commit/9572fcb4a0bd5396436689a6a42613886871cd81
190
+ # 7.1 stable backported the change in https://github.com/rails/rails/commit/c53ec4b60980036b43528829d4b0b7457f759224
191
+ schema_mapped_versions = if Gem::Dependency.new("railties", ">= 7.1.4").match?("railties", Gem.loaded_specs["railties"].version, true)
183
192
  ActiveRecord::Tasks::DatabaseTasks.db_configs_with_versions
184
193
  else
185
194
  db_configs = ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env)
@@ -217,7 +226,8 @@ module DataMigrate
217
226
  next unless primary?(db_config)
218
227
 
219
228
  with_temporary_pool(db_config) do |pool|
220
- unless database_exists?(pool.connection)
229
+ connection = pool.respond_to?(:lease_connection) ? pool.lease_connection : pool.connection
230
+ unless database_exists?(connection)
221
231
  create(db_config)
222
232
  if File.exist?(schema_dump_path(db_config))
223
233
  load_schema(db_config, schema_format, nil)
@@ -6,6 +6,7 @@ module DataMigrate
6
6
 
7
7
  @equal_to_or_higher_than_7_2 = Gem::Dependency.new("railties", ">= 7.2.0.alpha").match?("railties", Gem.loaded_specs["railties"].version, true)
8
8
  end
9
+
9
10
  def rails_version_equal_to_or_higher_than_7_1
10
11
  return @equal_to_or_higher_than_7_1 if defined?(@equal_to_or_higher_than_7_1)
11
12
 
@@ -1,3 +1,3 @@
1
1
  module DataMigrate
2
- VERSION = "11.1.0".freeze
2
+ VERSION = "11.3.0".freeze
3
3
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: data_migrate
3
3
  version: !ruby/object:Gem::Version
4
- version: 11.1.0
4
+ version: 11.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew J Vargo
8
8
  - Ilya Katz
9
9
  - Deborah Enomah
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-10-09 00:00:00.000000000 Z
13
+ date: 2025-03-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
@@ -189,33 +189,9 @@ executables: []
189
189
  extensions: []
190
190
  extra_rdoc_files: []
191
191
  files:
192
- - ".github/workflows/build.yml"
193
- - ".github/workflows/gempush.yml"
194
- - ".gitignore"
195
- - ".hound.yml"
196
- - ".overcommit.yml"
197
- - ".rbenv-gemsets"
198
- - ".rspec"
199
- - ".rubocop.yml"
200
- - ".ruby-style.yml"
201
- - Appraisals
202
192
  - Changelog.md
203
- - Gemfile
204
- - Gemfile.lock
205
193
  - LICENSE
206
194
  - README.md
207
- - Rakefile
208
- - data_migrate.gemspec
209
- - gemfiles/rails_6.1.gemfile
210
- - gemfiles/rails_6.1.gemfile.lock
211
- - gemfiles/rails_7.0.gemfile
212
- - gemfiles/rails_7.0.gemfile.lock
213
- - gemfiles/rails_7.1.gemfile
214
- - gemfiles/rails_7.1.gemfile.lock
215
- - gemfiles/rails_7.2.gemfile
216
- - gemfiles/rails_7.2.gemfile.lock
217
- - gemfiles/rails_8.0.gemfile
218
- - gemfiles/rails_8.0.gemfile.lock
219
195
  - lib/capistrano/data_migrate.rb
220
196
  - lib/capistrano/data_migrate/migrate.rb
221
197
  - lib/data_migrate.rb
@@ -237,37 +213,12 @@ files:
237
213
  - lib/generators/data_migration/data_migration_generator.rb
238
214
  - lib/generators/data_migration/templates/data_migration.rb
239
215
  - lib/generators/data_migration/templates/migration.rb
240
- - screenshot.png
241
- - spec/data_migrate/config_spec.rb
242
- - spec/data_migrate/data_migrator_spec.rb
243
- - spec/data_migrate/data_schema_migration_spec.rb
244
- - spec/data_migrate/data_spec.rb
245
- - spec/data_migrate/database_tasks_spec.rb
246
- - spec/data_migrate/migration.rb
247
- - spec/data_migrate/migration_context_spec.rb
248
- - spec/data_migrate/schema_dumper_spec.rb
249
- - spec/data_migrate/schema_migration_spec.rb
250
- - spec/data_migrate/status_service_spec.rb
251
- - spec/data_migrate/tasks/data_migrate_tasks_spec.rb
252
- - spec/db/data/20091231235959_some_name.rb
253
- - spec/db/data/20171231235959_super_update.rb
254
- - spec/db/data/20181128000207_excluded_file.rb.other_ext
255
- - spec/db/data/partial_schema/data_schema.rb
256
- - spec/db/data/partial_schema/test_data_schema.rb
257
- - spec/db/data/schema/data_schema.rb
258
- - spec/db/data/schema/test_data_schema.rb
259
- - spec/db/data_two/20241231235959_data_two_update.rb
260
- - spec/db/migrate/20131111111111_late_migration.rb
261
- - spec/db/migrate/20202020202011_db_migration.rb
262
- - spec/generators/data_migration/data_migration_generator_spec.rb
263
- - spec/spec_helper.rb
264
- - tasks/.gitkeep
265
216
  - tasks/databases.rake
266
217
  homepage: https://github.com/ilyakatz/data-migrate
267
218
  licenses:
268
219
  - MIT
269
220
  metadata: {}
270
- post_install_message:
221
+ post_install_message:
271
222
  rdoc_options: []
272
223
  require_paths:
273
224
  - lib
@@ -283,7 +234,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
283
234
  version: '0'
284
235
  requirements: []
285
236
  rubygems_version: 3.4.19
286
- signing_key:
237
+ signing_key:
287
238
  specification_version: 4
288
239
  summary: Rake tasks to migrate data alongside schema changes.
289
240
  test_files: []
@@ -1,39 +0,0 @@
1
- name: CI
2
-
3
- on:
4
- - push
5
- - pull_request
6
-
7
- jobs:
8
- test:
9
- strategy:
10
- fail-fast: false
11
- matrix:
12
- os: [ "ubuntu-24.04" ]
13
- ruby:
14
- - '3.1'
15
- - '3.2'
16
- - '3.3'
17
- gemfile:
18
- - gemfiles/rails_6.1.gemfile
19
- - gemfiles/rails_7.0.gemfile
20
- - gemfiles/rails_7.1.gemfile
21
- - gemfiles/rails_7.2.gemfile
22
- - gemfiles/rails_8.0.gemfile
23
- exclude:
24
- - ruby: '3.1'
25
- gemfile: 'gemfiles/rails_8.0.gemfile'
26
- runs-on: ubuntu-latest
27
- env:
28
- BUNDLE_GEMFILE: ${{ matrix.gemfile }}
29
- RAILS_ENV: test
30
- steps:
31
- - name: Checkout code
32
- uses: actions/checkout@v4
33
- - name: Set up Ruby
34
- uses: ruby/setup-ruby@v1
35
- with:
36
- ruby-version: ${{ matrix.ruby }}
37
- bundler-cache: true
38
- - name: Run tests
39
- run: bundle exec rspec
@@ -1,28 +0,0 @@
1
- name: Release Gem
2
-
3
- on:
4
- release:
5
- types: [released]
6
-
7
- jobs:
8
- build:
9
- name: Build + Publish
10
- runs-on: ubuntu-latest
11
-
12
- steps:
13
- - uses: actions/checkout@master
14
- - name: Set up Ruby 3.2
15
- uses: ruby/setup-ruby@v1
16
- with:
17
- ruby-version: '3.2'
18
-
19
- - name: Publish to RubyGems
20
- run: |
21
- mkdir -p $HOME/.gem
22
- touch $HOME/.gem/credentials
23
- chmod 0600 $HOME/.gem/credentials
24
- printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
25
- gem build *.gemspec
26
- gem push *.gem
27
- env:
28
- GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
data/.gitignore DELETED
@@ -1,12 +0,0 @@
1
- /.rvmrc
2
- *.gem
3
- gemfiles/.bundle
4
- spec/db/test.db
5
- spec/db/other_test.db
6
- spec/db/data_schema.rb
7
- .vscode/
8
- .DS_Store
9
- .ruby-gemset
10
- .ruby-version
11
- .idea/
12
- vendor/
data/.hound.yml DELETED
@@ -1,4 +0,0 @@
1
- fail_on_violations: true
2
-
3
- ruby:
4
- config_file: .rubocop.yml
data/.overcommit.yml DELETED
@@ -1,21 +0,0 @@
1
- # Use this file to configure the Overcommit hooks you wish to use. This will
2
- # extend the default configuration defined in:
3
- # https://github.com/brigade/overcommit/blob/master/config/default.yml
4
- #
5
- # At the topmost level of this YAML file is a key representing type of hook
6
- # being run (e.g. pre-commit, commit-msg, etc.). Within each type you can
7
- # customize each hook, such as whether to only run it on certain files (via
8
- # `include`), whether to only display output if it fails (via `quiet`), etc.
9
- #
10
- # For a complete list of hooks, see:
11
- # https://github.com/brigade/overcommit/tree/master/lib/overcommit/hook
12
- #
13
- # For a complete list of options that you can use to customize hooks, see:
14
- # https://github.com/brigade/overcommit#configuration
15
- #
16
- # Uncomment the following lines to make the configuration take effect.
17
-
18
- PreCommit:
19
- RuboCop:
20
- enabled: true
21
- on_warn: fail # Treat all warnings as failures
data/.rbenv-gemsets DELETED
@@ -1,2 +0,0 @@
1
- data-migrate
2
- -global
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --color
2
- --format d
3
-
data/.rubocop.yml DELETED
@@ -1,2 +0,0 @@
1
- # Use same configration as used by HoundCI
2
- inherit_from: .ruby-style.yml