data_migrate 9.3.0 → 9.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ef4acf6725174a7fa111477f13b0fa7229598c3a8034c55d4e6baae020bb8036
4
- data.tar.gz: 0c4ee40e59561410c9f31752d48952c141db6af9fdae0f5d83c476241ab7c1fa
3
+ metadata.gz: aa16e421f2f5d046c5e78678b226574ddaeca7345bfcff5f8ab69091fb901f3c
4
+ data.tar.gz: 91d60c54724dc47e6aac6f7638275c005c0f27f052741c00fbed0f15fb8056b7
5
5
  SHA512:
6
- metadata.gz: 4a10f7c62212a39ce6e0629a15e61f3be4e55cf93bcac0fb56a85506bfe0bc272833268558776361b14525196c257cb065825a93d17eed0f7a42185e1db162bb
7
- data.tar.gz: 19b397534a6274ffbfcbbe6d71c25dfb3f192a22d37e79491b65818a73906a1d04bed943c45c1f078605d5eff08cfcac23e2cfb1d2640a45ad0065446c44d4d7
6
+ metadata.gz: e0585dd9cc369cfbb980c609d1c7f1cc286a3109f799303d1518cca460f1e41b89df484154426e8e6798cd674f520241d19ab4bd2343bb0800e429de78b7d379
7
+ data.tar.gz: 52aeb1ce48bcf2644f8c4640b99d5dbb98bee62e10fa5f3a20fabff41eb3dc833c346c39b51245a128095eb75231d588ca734092056aedbff62bfa1df6512888
data/Changelog.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 9.4.1
4
+ - Add db:prepare task
5
+
6
+ ## 9.4.0
7
+ - Reset model schema cache before each data migration https://github.com/ilyakatz/data-migrate/pull/307
8
+ - Run load_config rake task before db:migrate:with_data https://github.com/ilyakatz/data-migrate/pull/308
9
+
3
10
  ## 9.3.0
4
11
  - Improve with_data Rake task for multiple database https://github.com/ilyakatz/data-migrate/pull/296
5
12
 
data/Gemfile.lock CHANGED
@@ -1,16 +1,16 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- data_migrate (9.3.0)
4
+ data_migrate (9.4.1)
5
5
  activerecord (>= 6.1)
6
6
  railties (>= 6.1)
7
7
 
8
8
  GEM
9
9
  remote: http://rubygems.org/
10
10
  specs:
11
- actionpack (7.1.3.2)
12
- actionview (= 7.1.3.2)
13
- activesupport (= 7.1.3.2)
11
+ actionpack (7.1.3.4)
12
+ actionview (= 7.1.3.4)
13
+ activesupport (= 7.1.3.4)
14
14
  nokogiri (>= 1.8.5)
15
15
  racc
16
16
  rack (>= 2.2.4)
@@ -18,19 +18,19 @@ GEM
18
18
  rack-test (>= 0.6.3)
19
19
  rails-dom-testing (~> 2.2)
20
20
  rails-html-sanitizer (~> 1.6)
21
- actionview (7.1.3.2)
22
- activesupport (= 7.1.3.2)
21
+ actionview (7.1.3.4)
22
+ activesupport (= 7.1.3.4)
23
23
  builder (~> 3.1)
24
24
  erubi (~> 1.11)
25
25
  rails-dom-testing (~> 2.2)
26
26
  rails-html-sanitizer (~> 1.6)
27
- activemodel (7.1.3.2)
28
- activesupport (= 7.1.3.2)
29
- activerecord (7.1.3.2)
30
- activemodel (= 7.1.3.2)
31
- activesupport (= 7.1.3.2)
27
+ activemodel (7.1.3.4)
28
+ activesupport (= 7.1.3.4)
29
+ activerecord (7.1.3.4)
30
+ activemodel (= 7.1.3.4)
31
+ activesupport (= 7.1.3.4)
32
32
  timeout (>= 0.4.0)
33
- activesupport (7.1.3.2)
33
+ activesupport (7.1.3.4)
34
34
  base64
35
35
  bigdecimal
36
36
  concurrent-ruby (~> 1.0, >= 1.0.2)
@@ -46,18 +46,17 @@ GEM
46
46
  thor (>= 0.14.0)
47
47
  ast (2.4.2)
48
48
  base64 (0.2.0)
49
- bigdecimal (3.1.6)
49
+ bigdecimal (3.1.8)
50
50
  builder (3.2.4)
51
51
  childprocess (5.0.0)
52
52
  coderay (1.1.3)
53
- concurrent-ruby (1.2.3)
53
+ concurrent-ruby (1.3.1)
54
54
  connection_pool (2.4.1)
55
55
  crass (1.0.6)
56
56
  diff-lcs (1.5.1)
57
- drb (2.2.0)
58
- ruby2_keywords
57
+ drb (2.2.1)
59
58
  erubi (1.12.0)
60
- i18n (1.14.1)
59
+ i18n (1.14.5)
61
60
  concurrent-ruby (~> 1.0)
62
61
  iniparse (1.5.0)
63
62
  io-console (0.7.2)
@@ -70,11 +69,11 @@ GEM
70
69
  crass (~> 1.0.2)
71
70
  nokogiri (>= 1.12.0)
72
71
  method_source (1.0.0)
73
- minitest (5.22.2)
72
+ minitest (5.23.1)
74
73
  mutex_m (0.2.0)
75
- nokogiri (1.16.2-arm64-darwin)
74
+ nokogiri (1.16.5-arm64-darwin)
76
75
  racc (~> 1.4)
77
- nokogiri (1.16.2-x86_64-linux)
76
+ nokogiri (1.16.5-x86_64-linux)
78
77
  racc (~> 1.4)
79
78
  overcommit (0.63.0)
80
79
  childprocess (>= 0.6.3, < 6)
@@ -89,8 +88,8 @@ GEM
89
88
  method_source (~> 1.0)
90
89
  psych (5.1.2)
91
90
  stringio
92
- racc (1.7.3)
93
- rack (3.0.9.1)
91
+ racc (1.8.0)
92
+ rack (3.0.11)
94
93
  rack-session (2.0.0)
95
94
  rack (>= 3.0.0)
96
95
  rack-test (2.1.0)
@@ -105,9 +104,9 @@ GEM
105
104
  rails-html-sanitizer (1.6.0)
106
105
  loofah (~> 2.21)
107
106
  nokogiri (~> 1.14)
108
- railties (7.1.3.2)
109
- actionpack (= 7.1.3.2)
110
- activesupport (= 7.1.3.2)
107
+ railties (7.1.3.4)
108
+ actionpack (= 7.1.3.4)
109
+ activesupport (= 7.1.3.4)
111
110
  irb
112
111
  rackup (>= 1.0.0)
113
112
  rake (>= 12.2)
@@ -116,12 +115,13 @@ GEM
116
115
  rainbow (3.1.1)
117
116
  rake (13.1.0)
118
117
  rb-readline (0.5.5)
119
- rdoc (6.6.2)
118
+ rdoc (6.6.3.1)
120
119
  psych (>= 4.0.0)
121
120
  regexp_parser (2.9.0)
122
121
  reline (0.4.3)
123
122
  io-console (~> 0.5)
124
- rexml (3.2.6)
123
+ rexml (3.2.8)
124
+ strscan (>= 3.0.9)
125
125
  rspec (3.13.0)
126
126
  rspec-core (~> 3.13.0)
127
127
  rspec-expectations (~> 3.13.0)
@@ -149,10 +149,10 @@ GEM
149
149
  rubocop-ast (1.30.0)
150
150
  parser (>= 3.2.1.0)
151
151
  ruby-progressbar (1.13.0)
152
- ruby2_keywords (0.0.5)
153
152
  sqlite3 (1.7.2-arm64-darwin)
154
153
  sqlite3 (1.7.2-x86_64-linux)
155
154
  stringio (3.1.0)
155
+ strscan (3.1.0)
156
156
  thor (1.3.1)
157
157
  timecop (0.9.8)
158
158
  timeout (0.4.1)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- data_migrate (9.3.0)
4
+ data_migrate (9.4.1)
5
5
  activerecord (>= 6.1)
6
6
  railties (>= 6.1)
7
7
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- data_migrate (9.3.0)
4
+ data_migrate (9.4.1)
5
5
  activerecord (>= 6.1)
6
6
  railties (>= 6.1)
7
7
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- data_migrate (9.3.0)
4
+ data_migrate (9.4.1)
5
5
  activerecord (>= 6.1)
6
6
  railties (>= 6.1)
7
7
 
@@ -54,6 +54,10 @@ module DataMigrate
54
54
 
55
55
  #TODO: this was added to be backward compatible, need to re-evaluate
56
56
  def run(direction, migration_paths, version)
57
+ # Ensure all Active Record model cache is reset for each data migration
58
+ # As recommended in: https://github.com/rails/rails/blob/da21c2e9812e5eb0698fba4a9aa38632fc004432/activerecord/lib/active_record/migration.rb#L467-L470
59
+ ActiveRecord::Base.descendants.each(&:reset_column_information)
60
+
57
61
  DataMigrate::MigrationContext.new(migration_paths).run(direction, version)
58
62
  end
59
63
 
@@ -173,5 +173,36 @@ module DataMigrate
173
173
 
174
174
  sort&.downcase == "asc" ? sort_migrations(migrations) : sort_migrations(migrations).reverse
175
175
  end
176
+
177
+ def self.migrate_with_data
178
+ DataMigrate::DataMigrator.create_data_schema_table
179
+
180
+ ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
181
+
182
+ db_configs = ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env)
183
+
184
+ schema_mapped_versions = ActiveRecord::Tasks::DatabaseTasks.db_configs_with_versions(db_configs)
185
+ data_mapped_versions = DataMigrate::DatabaseTasks.db_configs_with_versions
186
+
187
+ mapped_versions = schema_mapped_versions.merge(data_mapped_versions) do |_key, schema_db_configs, data_db_configs|
188
+ schema_db_configs + data_db_configs
189
+ end
190
+
191
+ mapped_versions.sort.each do |version, db_configs|
192
+ db_configs.each do |db_config|
193
+ if is_data_migration = db_config.is_a?(DataMigrate::DatabaseConfigurationWrapper)
194
+ db_config = db_config.db_config
195
+ end
196
+
197
+ DataMigrate::DatabaseTasks.with_temporary_connection(db_config) do
198
+ if is_data_migration
199
+ DataMigrate::DataMigrator.run(:up, DataMigrate::DatabaseTasks.data_migrations_path, version)
200
+ else
201
+ ActiveRecord::Tasks::DatabaseTasks.migrate(version)
202
+ end
203
+ end
204
+ end
205
+ end
206
+ end
176
207
  end
177
208
  end
@@ -1,3 +1,3 @@
1
1
  module DataMigrate
2
- VERSION = "9.3.0".freeze
2
+ VERSION = "9.4.1".freeze
3
3
  end
data/tasks/databases.rake CHANGED
@@ -5,35 +5,8 @@ require 'data_migrate/tasks/data_migrate_tasks'
5
5
  namespace :db do
6
6
  namespace :migrate do
7
7
  desc "Migrate the database data and schema (options: VERSION=x, VERBOSE=false)."
8
- task :with_data => :environment do
9
- DataMigrate::DataMigrator.create_data_schema_table
10
- ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
11
-
12
- db_configs = ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env)
13
-
14
- schema_mapped_versions = ActiveRecord::Tasks::DatabaseTasks.db_configs_with_versions(db_configs)
15
- data_mapped_versions = DataMigrate::DatabaseTasks.db_configs_with_versions
16
-
17
- mapped_versions = schema_mapped_versions.merge(data_mapped_versions) do |_key, schema_db_configs, data_db_configs|
18
- schema_db_configs + data_db_configs
19
- end
20
-
21
- mapped_versions.sort.each do |version, db_configs|
22
- db_configs.each do |db_config|
23
- if is_data_migration = db_config.is_a?(DataMigrate::DatabaseConfigurationWrapper)
24
- db_config = db_config.db_config
25
- end
26
-
27
- DataMigrate::DatabaseTasks.with_temporary_connection(db_config) do
28
- if is_data_migration
29
- DataMigrate::DataMigrator.run(:up, DataMigrate::DatabaseTasks.data_migrations_path, version)
30
- else
31
- ActiveRecord::Tasks::DatabaseTasks.migrate(version)
32
- end
33
- end
34
- end
35
- end
36
-
8
+ task :with_data => :load_config do
9
+ DataMigrate::DatabaseTasks.migrate_with_data
37
10
  Rake::Task["db:_dump"].invoke
38
11
  Rake::Task["data:dump"].invoke
39
12
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: data_migrate
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.3.0
4
+ version: 9.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew J Vargo
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-03-02 00:00:00.000000000 Z
13
+ date: 2024-08-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord