data_migrate 5.1.0 → 6.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rbenv-gemsets +2 -0
- data/.ruby-version +1 -0
- data/.travis.yml +7 -4
- data/Appraisals +7 -9
- data/Changelog.md +44 -3
- data/Gemfile +2 -0
- data/Gemfile.rails5.1 +1 -1
- data/README.md +30 -18
- data/data_migrate.gemspec +2 -2
- data/gemfiles/rails_4.2.gemfile +2 -1
- data/gemfiles/rails_5.0.gemfile +1 -1
- data/gemfiles/rails_5.1.gemfile +1 -1
- data/gemfiles/rails_5.2.gemfile +1 -1
- data/gemfiles/rails_6.0.gemfile +8 -0
- data/lib/capistrano/data_migrate/migrate.rb +3 -4
- data/lib/data_migrate.rb +14 -10
- data/lib/data_migrate/config.rb +21 -0
- data/lib/data_migrate/data_migrator.rb +20 -14
- data/lib/data_migrate/data_migrator_five.rb +10 -3
- data/lib/data_migrate/database_tasks.rb +3 -1
- data/lib/data_migrate/schema_migration_five.rb +1 -1
- data/lib/data_migrate/schema_migration_six.rb +31 -0
- data/lib/data_migrate/status_service.rb +1 -1
- data/lib/data_migrate/tasks/data_migrate_tasks.rb +4 -8
- data/lib/data_migrate/version.rb +1 -1
- data/lib/generators/data_migration/data_migration_generator.rb +10 -1
- data/spec/data_migrate/config_spec.rb +27 -0
- data/spec/data_migrate/data_migrator_spec.rb +21 -0
- data/spec/data_migrate/database_tasks_spec.rb +4 -10
- data/spec/data_migrate/migration_context_spec.rb +13 -4
- data/spec/data_migrate/schema_migration_spec.rb +3 -1
- data/spec/data_migrate/status_service_spec.rb +10 -1
- data/spec/data_migrate/tasks/data_migrate_tasks_spec.rb +2 -17
- data/spec/db/{4.2 → 6.0}/20091231235959_some_name.rb +1 -1
- data/spec/db/{4.2 → 6.0}/20171231235959_super_update.rb +1 -1
- data/spec/db/data-6.0/20091231235959_some_name.rb +9 -0
- data/spec/db/data-6.0/20171231235959_super_update.rb +9 -0
- data/spec/db/data-6.0/20181128000207_excluded_file.rb.other_ext +1 -0
- data/spec/db/data/20181128000207_excluded_file.rb.other_ext +1 -0
- data/spec/db/migrate/6.0/20131111111111_late_migration.rb +9 -0
- data/spec/db/migrate/6.0/20202020202011_db_migration.rb +9 -0
- data/spec/generators/data_migration/data_migration_generator_spec.rb +33 -0
- data/spec/spec_helper.rb +26 -4
- data/tasks/databases.rake +14 -10
- metadata +32 -14
data/spec/spec_helper.rb
CHANGED
@@ -1,15 +1,37 @@
|
|
1
1
|
require 'rspec'
|
2
2
|
require 'rails'
|
3
|
+
require 'sqlite3'
|
3
4
|
require 'data_migrate'
|
4
5
|
require 'pry'
|
5
6
|
require 'timecop'
|
6
7
|
|
7
|
-
if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR == 2
|
8
|
-
DataMigrate::DataMigrator.migrations_paths = ["spec/db/data"]
|
9
|
-
end
|
10
|
-
|
11
8
|
RSpec.configure do |config|
|
12
9
|
config.mock_with :rspec do |mocks|
|
13
10
|
mocks.verify_partial_doubles = true
|
14
11
|
end
|
12
|
+
|
13
|
+
config.before(:each) do |example|
|
14
|
+
if example.metadata[:no_override]
|
15
|
+
else
|
16
|
+
if Rails::VERSION::MAJOR == 6
|
17
|
+
DataMigrate.configure do |config|
|
18
|
+
config.data_migrations_path = "spec/db/6.0"
|
19
|
+
end
|
20
|
+
elsif Rails::VERSION::MAJOR == 5
|
21
|
+
if Rails::VERSION::MINOR == 2
|
22
|
+
DataMigrate.configure do |config|
|
23
|
+
config.data_migrations_path = "spec/db/data"
|
24
|
+
end
|
25
|
+
else
|
26
|
+
DataMigrate.configure do |config|
|
27
|
+
config.data_migrations_path = "spec/db/5.0"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
else
|
31
|
+
DataMigrate.configure do |config|
|
32
|
+
config.data_migrations_path = "spec/db/5.0"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
15
37
|
end
|
data/tasks/databases.rake
CHANGED
@@ -48,7 +48,7 @@ namespace :db do
|
|
48
48
|
migrations.each do |migration|
|
49
49
|
if migration[:kind] == :data
|
50
50
|
ActiveRecord::Migration.write("== %s %s" % ['Data', "=" * 71])
|
51
|
-
DataMigrate::DataMigrator.run(migration[:direction],
|
51
|
+
DataMigrate::DataMigrator.run(migration[:direction], data_migrations_path, migration[:version])
|
52
52
|
else
|
53
53
|
ActiveRecord::Migration.write("== %s %s" % ['Schema', "=" * 69])
|
54
54
|
DataMigrate::SchemaMigration.run(
|
@@ -93,7 +93,7 @@ namespace :db do
|
|
93
93
|
migrations.each do |migration|
|
94
94
|
if migration[:kind] == :data
|
95
95
|
ActiveRecord::Migration.write("== %s %s" % ['Data', "=" * 71])
|
96
|
-
DataMigrate::DataMigrator.run(:up,
|
96
|
+
DataMigrate::DataMigrator.run(:up, data_migrations_path, migration[:version])
|
97
97
|
else
|
98
98
|
ActiveRecord::Migration.write("== %s %s" % ['Schema', "=" * 69])
|
99
99
|
DataMigrate::SchemaMigration.run(:up, "db/migrate/", migration[:version])
|
@@ -121,7 +121,7 @@ namespace :db do
|
|
121
121
|
migrations.each do |migration|
|
122
122
|
if migration[:kind] == :data
|
123
123
|
ActiveRecord::Migration.write("== %s %s" % ['Data', "=" * 71])
|
124
|
-
DataMigrate::DataMigrator.run(:down,
|
124
|
+
DataMigrate::DataMigrator.run(:down, data_migrations_path, migration[:version])
|
125
125
|
else
|
126
126
|
ActiveRecord::Migration.write("== %s %s" % ['Schema', "=" * 69])
|
127
127
|
DataMigrate::SchemaMigration.run(:down, "db/migrate/", migration[:version])
|
@@ -147,7 +147,7 @@ namespace :db do
|
|
147
147
|
)
|
148
148
|
file_list = []
|
149
149
|
|
150
|
-
Dir.foreach(File.join(Rails.root,
|
150
|
+
Dir.foreach(File.join(Rails.root, data_migrations_path)) do |file|
|
151
151
|
# only files matching "20091231235959_some_name.rb" pattern
|
152
152
|
if match_data = /(\d{14})_(.+)\.rb/.match(file)
|
153
153
|
status = db_list_data.delete(match_data[1]) ? 'up' : 'down'
|
@@ -191,10 +191,10 @@ namespace :db do
|
|
191
191
|
past_migrations[0..(step - 1)].each do | past_migration |
|
192
192
|
if past_migration[:kind] == :data
|
193
193
|
ActiveRecord::Migration.write("== %s %s" % ['Data', "=" * 71])
|
194
|
-
DataMigrate::DataMigrator.run(:down,
|
194
|
+
DataMigrate::DataMigrator.run(:down, data_migrations_path, past_migration[:version])
|
195
195
|
elsif past_migration[:kind] == :schema
|
196
196
|
ActiveRecord::Migration.write("== %s %s" % ['Schema', "=" * 69])
|
197
|
-
|
197
|
+
DataMigrate::SchemaMigration.run(:down, "db/migrate/", past_migration[:version])
|
198
198
|
end
|
199
199
|
end
|
200
200
|
|
@@ -277,7 +277,7 @@ namespace :data do
|
|
277
277
|
assure_data_schema_table
|
278
278
|
version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
|
279
279
|
raise "VERSION is required" unless version
|
280
|
-
DataMigrate::DataMigrator.run(:up,
|
280
|
+
DataMigrate::DataMigrator.run(:up, data_migrations_path, version)
|
281
281
|
Rake::Task["data:dump"].invoke
|
282
282
|
end
|
283
283
|
|
@@ -286,7 +286,7 @@ namespace :data do
|
|
286
286
|
version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
|
287
287
|
raise "VERSION is required" unless version
|
288
288
|
assure_data_schema_table
|
289
|
-
DataMigrate::DataMigrator.run(:down,
|
289
|
+
DataMigrate::DataMigrator.run(:down, data_migrations_path, version)
|
290
290
|
Rake::Task["data:dump"].invoke
|
291
291
|
end
|
292
292
|
|
@@ -304,7 +304,7 @@ namespace :data do
|
|
304
304
|
task :rollback => :environment do
|
305
305
|
assure_data_schema_table
|
306
306
|
step = ENV['STEP'] ? ENV['STEP'].to_i : 1
|
307
|
-
DataMigrate::DataMigrator.rollback(
|
307
|
+
DataMigrate::DataMigrator.rollback(data_migrations_path, step)
|
308
308
|
Rake::Task["data:dump"].invoke
|
309
309
|
end
|
310
310
|
|
@@ -316,7 +316,7 @@ namespace :data do
|
|
316
316
|
# DataMigrate::DataMigrator.forward('db/data/', step)
|
317
317
|
migrations = pending_data_migrations.reverse.pop(step).reverse
|
318
318
|
migrations.each do | pending_migration |
|
319
|
-
DataMigrate::DataMigrator.run(:up,
|
319
|
+
DataMigrate::DataMigrator.run(:up, data_migrations_path, pending_migration[:version])
|
320
320
|
end
|
321
321
|
Rake::Task["data:dump"].invoke
|
322
322
|
end
|
@@ -389,3 +389,7 @@ end
|
|
389
389
|
def assure_data_schema_table
|
390
390
|
DataMigrate::DataMigrator.assure_data_schema_table
|
391
391
|
end
|
392
|
+
|
393
|
+
def data_migrations_path
|
394
|
+
DataMigrate.config.data_migrations_path
|
395
|
+
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:
|
4
|
+
version: 6.0.5
|
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:
|
13
|
+
date: 2019-10-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -18,14 +18,14 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ">="
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
21
|
+
version: '5.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: '
|
28
|
+
version: '5.0'
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: appraisal
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,16 +114,16 @@ dependencies:
|
|
114
114
|
name: sqlite3
|
115
115
|
requirement: !ruby/object:Gem::Requirement
|
116
116
|
requirements:
|
117
|
-
- - "
|
117
|
+
- - "~>"
|
118
118
|
- !ruby/object:Gem::Version
|
119
|
-
version:
|
119
|
+
version: 1.3.6
|
120
120
|
type: :development
|
121
121
|
prerelease: false
|
122
122
|
version_requirements: !ruby/object:Gem::Requirement
|
123
123
|
requirements:
|
124
|
-
- - "
|
124
|
+
- - "~>"
|
125
125
|
- !ruby/object:Gem::Version
|
126
|
-
version:
|
126
|
+
version: 1.3.6
|
127
127
|
- !ruby/object:Gem::Dependency
|
128
128
|
name: timecop
|
129
129
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,9 +178,11 @@ files:
|
|
178
178
|
- ".gitignore"
|
179
179
|
- ".hound.yml"
|
180
180
|
- ".overcommit.yml"
|
181
|
+
- ".rbenv-gemsets"
|
181
182
|
- ".rspec"
|
182
183
|
- ".rubocop.yml"
|
183
184
|
- ".ruby-style.yml"
|
185
|
+
- ".ruby-version"
|
184
186
|
- ".travis.yml"
|
185
187
|
- Appraisals
|
186
188
|
- Changelog.md
|
@@ -197,9 +199,11 @@ files:
|
|
197
199
|
- gemfiles/rails_5.0.gemfile
|
198
200
|
- gemfiles/rails_5.1.gemfile
|
199
201
|
- gemfiles/rails_5.2.gemfile
|
202
|
+
- gemfiles/rails_6.0.gemfile
|
200
203
|
- lib/capistrano/data_migrate.rb
|
201
204
|
- lib/capistrano/data_migrate/migrate.rb
|
202
205
|
- lib/data_migrate.rb
|
206
|
+
- lib/data_migrate/config.rb
|
203
207
|
- lib/data_migrate/data_migrator.rb
|
204
208
|
- lib/data_migrate/data_migrator_five.rb
|
205
209
|
- lib/data_migrate/data_schema.rb
|
@@ -213,6 +217,7 @@ files:
|
|
213
217
|
- lib/data_migrate/schema_dumper.rb
|
214
218
|
- lib/data_migrate/schema_migration.rb
|
215
219
|
- lib/data_migrate/schema_migration_five.rb
|
220
|
+
- lib/data_migrate/schema_migration_six.rb
|
216
221
|
- lib/data_migrate/status_service.rb
|
217
222
|
- lib/data_migrate/status_service_five.rb
|
218
223
|
- lib/data_migrate/tasks/data_migrate_tasks.rb
|
@@ -222,6 +227,7 @@ files:
|
|
222
227
|
- lib/generators/data_migration/templates/data_migration.rb
|
223
228
|
- lib/generators/data_migration/templates/migration.rb
|
224
229
|
- screenshot.png
|
230
|
+
- spec/data_migrate/config_spec.rb
|
225
231
|
- spec/data_migrate/data_migrator_spec.rb
|
226
232
|
- spec/data_migrate/data_schema_migration_spec.rb
|
227
233
|
- spec/data_migrate/data_spec.rb
|
@@ -233,18 +239,24 @@ files:
|
|
233
239
|
- spec/data_migrate/schema_migration_spec.rb
|
234
240
|
- spec/data_migrate/status_service_spec.rb
|
235
241
|
- spec/data_migrate/tasks/data_migrate_tasks_spec.rb
|
236
|
-
- spec/db/4.2/20091231235959_some_name.rb
|
237
|
-
- spec/db/4.2/20171231235959_super_update.rb
|
238
242
|
- spec/db/5.0/20091231235959_some_name.rb
|
239
243
|
- spec/db/5.0/20171231235959_super_update.rb
|
244
|
+
- spec/db/6.0/20091231235959_some_name.rb
|
245
|
+
- spec/db/6.0/20171231235959_super_update.rb
|
246
|
+
- spec/db/data-6.0/20091231235959_some_name.rb
|
247
|
+
- spec/db/data-6.0/20171231235959_super_update.rb
|
248
|
+
- spec/db/data-6.0/20181128000207_excluded_file.rb.other_ext
|
240
249
|
- spec/db/data/20091231235959_some_name.rb
|
241
250
|
- spec/db/data/20171231235959_super_update.rb
|
251
|
+
- spec/db/data/20181128000207_excluded_file.rb.other_ext
|
242
252
|
- spec/db/migrate/4.2/20131111111111_late_migration.rb
|
243
253
|
- spec/db/migrate/4.2/20202020202011_db_migration.rb
|
244
254
|
- spec/db/migrate/5.0/20131111111111_late_migration.rb
|
245
255
|
- spec/db/migrate/5.0/20202020202011_db_migration.rb
|
246
256
|
- spec/db/migrate/5.2/20131111111111_late_migration.rb
|
247
257
|
- spec/db/migrate/5.2/20202020202011_db_migration.rb
|
258
|
+
- spec/db/migrate/6.0/20131111111111_late_migration.rb
|
259
|
+
- spec/db/migrate/6.0/20202020202011_db_migration.rb
|
248
260
|
- spec/generators/data_migration/data_migration_generator_spec.rb
|
249
261
|
- spec/spec_helper.rb
|
250
262
|
- tasks/.gitkeep
|
@@ -274,12 +286,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
274
286
|
- !ruby/object:Gem::Version
|
275
287
|
version: '0'
|
276
288
|
requirements: []
|
277
|
-
|
278
|
-
rubygems_version: 2.6.13
|
289
|
+
rubygems_version: 3.0.1
|
279
290
|
signing_key:
|
280
291
|
specification_version: 4
|
281
292
|
summary: Rake tasks to migrate data alongside schema changes.
|
282
293
|
test_files:
|
294
|
+
- spec/data_migrate/config_spec.rb
|
283
295
|
- spec/data_migrate/data_migrator_spec.rb
|
284
296
|
- spec/data_migrate/data_schema_migration_spec.rb
|
285
297
|
- spec/data_migrate/data_spec.rb
|
@@ -291,17 +303,23 @@ test_files:
|
|
291
303
|
- spec/data_migrate/schema_migration_spec.rb
|
292
304
|
- spec/data_migrate/status_service_spec.rb
|
293
305
|
- spec/data_migrate/tasks/data_migrate_tasks_spec.rb
|
294
|
-
- spec/db/4.2/20091231235959_some_name.rb
|
295
|
-
- spec/db/4.2/20171231235959_super_update.rb
|
296
306
|
- spec/db/5.0/20091231235959_some_name.rb
|
297
307
|
- spec/db/5.0/20171231235959_super_update.rb
|
308
|
+
- spec/db/6.0/20091231235959_some_name.rb
|
309
|
+
- spec/db/6.0/20171231235959_super_update.rb
|
310
|
+
- spec/db/data-6.0/20091231235959_some_name.rb
|
311
|
+
- spec/db/data-6.0/20171231235959_super_update.rb
|
312
|
+
- spec/db/data-6.0/20181128000207_excluded_file.rb.other_ext
|
298
313
|
- spec/db/data/20091231235959_some_name.rb
|
299
314
|
- spec/db/data/20171231235959_super_update.rb
|
315
|
+
- spec/db/data/20181128000207_excluded_file.rb.other_ext
|
300
316
|
- spec/db/migrate/4.2/20131111111111_late_migration.rb
|
301
317
|
- spec/db/migrate/4.2/20202020202011_db_migration.rb
|
302
318
|
- spec/db/migrate/5.0/20131111111111_late_migration.rb
|
303
319
|
- spec/db/migrate/5.0/20202020202011_db_migration.rb
|
304
320
|
- spec/db/migrate/5.2/20131111111111_late_migration.rb
|
305
321
|
- spec/db/migrate/5.2/20202020202011_db_migration.rb
|
322
|
+
- spec/db/migrate/6.0/20131111111111_late_migration.rb
|
323
|
+
- spec/db/migrate/6.0/20202020202011_db_migration.rb
|
306
324
|
- spec/generators/data_migration/data_migration_generator_spec.rb
|
307
325
|
- spec/spec_helper.rb
|