data_migrate 9.4.0 → 9.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +6 -0
- data/Gemfile.lock +27 -27
- data/gemfiles/rails_6.1.gemfile.lock +1 -1
- data/gemfiles/rails_7.0.gemfile.lock +1 -1
- data/gemfiles/rails_7.1.gemfile.lock +1 -1
- data/lib/data_migrate/database_tasks.rb +68 -0
- data/lib/data_migrate/version.rb +1 -1
- data/tasks/databases.rake +8 -28
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b061a1b90d162a48df5225719ec96da94aaa77d0580d952a1ff0f4cb895e452e
|
4
|
+
data.tar.gz: bc78e03d816377c6a784b8102ce9f6c9504ee4650839436a92b1a949bce6a45d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c612eefd1985b3935c79c87039f1f67db81088a1984fb4e90d15c361d9c0fd90b9acefaeb131ec4b77f22a56f6524a99444e663b5e2e2a820115864b09471ed
|
7
|
+
data.tar.gz: b2ce56c6fd8510adb0eb465fc765df93fdce42f6d7f81e809276bbaf29f7e1891dd7638191e395af0afb774f1ced8fc33387a9619b09edf24cde824b03aa00a6
|
data/Changelog.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 9.4.2
|
4
|
+
- Fix db:prepare:with_data task
|
5
|
+
|
6
|
+
## 9.4.1
|
7
|
+
- Add db:prepare task
|
8
|
+
|
3
9
|
## 9.4.0
|
4
10
|
- Reset model schema cache before each data migration https://github.com/ilyakatz/data-migrate/pull/307
|
5
11
|
- Run load_config rake task before db:migrate:with_data https://github.com/ilyakatz/data-migrate/pull/308
|
data/Gemfile.lock
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
data_migrate (9.4.
|
4
|
+
data_migrate (9.4.2)
|
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.
|
12
|
-
actionview (= 7.1.3.
|
13
|
-
activesupport (= 7.1.3.
|
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.
|
22
|
-
activesupport (= 7.1.3.
|
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.
|
28
|
-
activesupport (= 7.1.3.
|
29
|
-
activerecord (7.1.3.
|
30
|
-
activemodel (= 7.1.3.
|
31
|
-
activesupport (= 7.1.3.
|
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.
|
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.
|
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.
|
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.
|
58
|
-
ruby2_keywords
|
57
|
+
drb (2.2.1)
|
59
58
|
erubi (1.12.0)
|
60
|
-
i18n (1.14.
|
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.
|
72
|
+
minitest (5.23.1)
|
74
73
|
mutex_m (0.2.0)
|
75
|
-
nokogiri (1.16.
|
74
|
+
nokogiri (1.16.5-arm64-darwin)
|
76
75
|
racc (~> 1.4)
|
77
|
-
nokogiri (1.16.
|
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.
|
93
|
-
rack (3.0.
|
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.
|
109
|
-
actionpack (= 7.1.3.
|
110
|
-
activesupport (= 7.1.3.
|
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)
|
@@ -121,7 +120,8 @@ GEM
|
|
121
120
|
regexp_parser (2.9.0)
|
122
121
|
reline (0.4.3)
|
123
122
|
io-console (~> 0.5)
|
124
|
-
rexml (3.2.
|
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)
|
@@ -173,5 +173,73 @@ 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
|
207
|
+
|
208
|
+
def self.prepare_all_with_data
|
209
|
+
seed = false
|
210
|
+
|
211
|
+
each_current_configuration(env) do |db_config|
|
212
|
+
next unless db_config.primary?
|
213
|
+
|
214
|
+
with_temporary_pool(db_config) do
|
215
|
+
begin
|
216
|
+
database_initialized = migration_connection.schema_migration.table_exists?
|
217
|
+
rescue ActiveRecord::NoDatabaseError
|
218
|
+
create(db_config)
|
219
|
+
retry
|
220
|
+
end
|
221
|
+
|
222
|
+
unless database_initialized
|
223
|
+
if File.exist?(schema_dump_path(db_config))
|
224
|
+
load_schema(db_config, ActiveRecord.schema_format, nil)
|
225
|
+
load_schema_current(
|
226
|
+
:ruby,
|
227
|
+
ENV["DATA_SCHEMA"]
|
228
|
+
)
|
229
|
+
end
|
230
|
+
|
231
|
+
seed = true
|
232
|
+
end
|
233
|
+
|
234
|
+
migrate_with_data
|
235
|
+
if ActiveRecord.dump_schema_after_migration
|
236
|
+
dump_schema(db_config)
|
237
|
+
DataMigrate::Tasks::DataMigrateTasks.dump
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
load_seed if seed
|
243
|
+
end
|
176
244
|
end
|
177
245
|
end
|
data/lib/data_migrate/version.rb
CHANGED
data/tasks/databases.rake
CHANGED
@@ -6,34 +6,7 @@ namespace :db do
|
|
6
6
|
namespace :migrate do
|
7
7
|
desc "Migrate the database data and schema (options: VERSION=x, VERBOSE=false)."
|
8
8
|
task :with_data => :load_config do
|
9
|
-
DataMigrate::
|
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
|
-
|
9
|
+
DataMigrate::DatabaseTasks.migrate_with_data
|
37
10
|
Rake::Task["db:_dump"].invoke
|
38
11
|
Rake::Task["data:dump"].invoke
|
39
12
|
end
|
@@ -173,6 +146,13 @@ namespace :db do
|
|
173
146
|
end
|
174
147
|
end
|
175
148
|
end
|
149
|
+
|
150
|
+
namespace :prepare do
|
151
|
+
desc "Runs setup if database does not exist, or runs data and schema migrations if it does"
|
152
|
+
task with_data: :environment do
|
153
|
+
DataMigrate::DatabaseTasks.prepare_all_with_data
|
154
|
+
end
|
155
|
+
end
|
176
156
|
end
|
177
157
|
|
178
158
|
namespace :data do
|
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.4.
|
4
|
+
version: 9.4.2
|
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-
|
13
|
+
date: 2024-08-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|