data_migrate 8.5.0 → 9.2.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.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +34 -0
- data/.github/workflows/gempush.yml +6 -7
- data/.gitignore +3 -2
- data/Appraisals +5 -9
- data/Changelog.md +44 -0
- data/Gemfile.lock +148 -0
- data/README.md +9 -7
- data/data_migrate.gemspec +1 -10
- data/gemfiles/rails_6.1.gemfile +1 -1
- data/gemfiles/rails_6.1.gemfile.lock +227 -0
- data/gemfiles/rails_7.0.gemfile.lock +229 -0
- data/gemfiles/{rails_6.0.gemfile → rails_7.1.gemfile} +1 -1
- data/gemfiles/rails_7.1.gemfile.lock +262 -0
- data/lib/data_migrate/config.rb +1 -1
- data/lib/data_migrate/{data_migrator_five.rb → data_migrator.rb} +11 -34
- data/lib/data_migrate/data_schema.rb +2 -2
- data/lib/data_migrate/data_schema_migration.rb +24 -7
- data/lib/data_migrate/database_tasks.rb +37 -74
- data/lib/data_migrate/migration_context.rb +11 -8
- data/lib/data_migrate/rails_helper.rb +79 -0
- data/lib/data_migrate/schema_dumper.rb +1 -1
- data/lib/data_migrate/{schema_migration_six.rb → schema_migration.rb} +7 -4
- data/lib/data_migrate/{status_service_five.rb → status_service.rb} +14 -8
- data/lib/data_migrate/tasks/data_migrate_tasks.rb +16 -37
- data/lib/data_migrate/version.rb +1 -1
- data/lib/data_migrate.rb +4 -9
- data/spec/data_migrate/config_spec.rb +13 -10
- data/spec/data_migrate/data_migrator_spec.rb +25 -43
- data/spec/data_migrate/data_schema_migration_spec.rb +25 -8
- data/spec/data_migrate/data_spec.rb +1 -12
- data/spec/data_migrate/database_tasks_spec.rb +43 -76
- data/spec/data_migrate/migration.rb +11 -13
- data/spec/data_migrate/migration_context_spec.rb +20 -39
- data/spec/data_migrate/schema_dumper_spec.rb +11 -21
- data/spec/data_migrate/schema_migration_spec.rb +46 -41
- data/spec/data_migrate/status_service_spec.rb +29 -55
- data/spec/data_migrate/tasks/data_migrate_tasks_spec.rb +32 -67
- data/spec/db/data/20091231235959_some_name.rb +1 -1
- data/spec/db/data/20171231235959_super_update.rb +1 -1
- data/spec/db/migrate/{5.2/20131111111111_late_migration.rb → 20131111111111_late_migration.rb} +1 -1
- data/spec/db/migrate/{6.0/20202020202011_db_migration.rb → 20202020202011_db_migration.rb} +1 -1
- data/spec/spec_helper.rb +2 -8
- data/tasks/databases.rake +15 -13
- metadata +20 -34
- data/.ruby-version +0 -1
- data/.travis.yml +0 -14
- data/Gemfile.rails5.2 +0 -10
- data/gemfiles/rails_5.2.gemfile +0 -8
- data/lib/data_migrate/legacy_migrator.rb +0 -22
- data/lib/data_migrate/schema_migration_five.rb +0 -31
- data/spec/data_migrate/legacy_migrator_spec.rb +0 -50
- data/spec/db/6.0/20091231235959_some_name.rb +0 -9
- data/spec/db/6.0/20171231235959_super_update.rb +0 -9
- data/spec/db/data-6.0/20091231235959_some_name.rb +0 -9
- data/spec/db/data-6.0/20171231235959_super_update.rb +0 -9
- data/spec/db/data-6.0/20181128000207_excluded_file.rb.other_ext +0 -1
- data/spec/db/migrate/5.2/20202020202011_db_migration.rb +0 -9
- data/spec/db/migrate/6.0/20131111111111_late_migration.rb +0 -9
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: 9.2.0
|
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: 2023-
|
13
|
+
date: 2023-10-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -18,28 +18,28 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ">="
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
21
|
+
version: '6.1'
|
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: '6.1'
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: railties
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
33
|
- - ">="
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: '
|
35
|
+
version: '6.1'
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '
|
42
|
+
version: '6.1'
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: appraisal
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -189,6 +189,7 @@ executables: []
|
|
189
189
|
extensions: []
|
190
190
|
extra_rdoc_files: []
|
191
191
|
files:
|
192
|
+
- ".github/workflows/build.yml"
|
192
193
|
- ".github/workflows/gempush.yml"
|
193
194
|
- ".gitignore"
|
194
195
|
- ".hound.yml"
|
@@ -197,36 +198,35 @@ files:
|
|
197
198
|
- ".rspec"
|
198
199
|
- ".rubocop.yml"
|
199
200
|
- ".ruby-style.yml"
|
200
|
-
- ".ruby-version"
|
201
|
-
- ".travis.yml"
|
202
201
|
- Appraisals
|
203
202
|
- Changelog.md
|
204
203
|
- Gemfile
|
205
|
-
- Gemfile.
|
204
|
+
- Gemfile.lock
|
206
205
|
- Gemfile.rails6.1
|
207
206
|
- LICENSE
|
208
207
|
- README.md
|
209
208
|
- Rakefile
|
210
209
|
- data_migrate.gemspec
|
211
|
-
- gemfiles/rails_5.2.gemfile
|
212
|
-
- gemfiles/rails_6.0.gemfile
|
213
210
|
- gemfiles/rails_6.1.gemfile
|
211
|
+
- gemfiles/rails_6.1.gemfile.lock
|
214
212
|
- gemfiles/rails_7.0.gemfile
|
213
|
+
- gemfiles/rails_7.0.gemfile.lock
|
214
|
+
- gemfiles/rails_7.1.gemfile
|
215
|
+
- gemfiles/rails_7.1.gemfile.lock
|
215
216
|
- lib/capistrano/data_migrate.rb
|
216
217
|
- lib/capistrano/data_migrate/migrate.rb
|
217
218
|
- lib/data_migrate.rb
|
218
219
|
- lib/data_migrate/config.rb
|
219
|
-
- lib/data_migrate/
|
220
|
+
- lib/data_migrate/data_migrator.rb
|
220
221
|
- lib/data_migrate/data_schema.rb
|
221
222
|
- lib/data_migrate/data_schema_migration.rb
|
222
223
|
- lib/data_migrate/database_tasks.rb
|
223
|
-
- lib/data_migrate/legacy_migrator.rb
|
224
224
|
- lib/data_migrate/migration_context.rb
|
225
|
+
- lib/data_migrate/rails_helper.rb
|
225
226
|
- lib/data_migrate/railtie.rb
|
226
227
|
- lib/data_migrate/schema_dumper.rb
|
227
|
-
- lib/data_migrate/
|
228
|
-
- lib/data_migrate/
|
229
|
-
- lib/data_migrate/status_service_five.rb
|
228
|
+
- lib/data_migrate/schema_migration.rb
|
229
|
+
- lib/data_migrate/status_service.rb
|
230
230
|
- lib/data_migrate/tasks/data_migrate_tasks.rb
|
231
231
|
- lib/data_migrate/version.rb
|
232
232
|
- lib/generators/data_migrate.rb
|
@@ -239,18 +239,12 @@ files:
|
|
239
239
|
- spec/data_migrate/data_schema_migration_spec.rb
|
240
240
|
- spec/data_migrate/data_spec.rb
|
241
241
|
- spec/data_migrate/database_tasks_spec.rb
|
242
|
-
- spec/data_migrate/legacy_migrator_spec.rb
|
243
242
|
- spec/data_migrate/migration.rb
|
244
243
|
- spec/data_migrate/migration_context_spec.rb
|
245
244
|
- spec/data_migrate/schema_dumper_spec.rb
|
246
245
|
- spec/data_migrate/schema_migration_spec.rb
|
247
246
|
- spec/data_migrate/status_service_spec.rb
|
248
247
|
- spec/data_migrate/tasks/data_migrate_tasks_spec.rb
|
249
|
-
- spec/db/6.0/20091231235959_some_name.rb
|
250
|
-
- spec/db/6.0/20171231235959_super_update.rb
|
251
|
-
- spec/db/data-6.0/20091231235959_some_name.rb
|
252
|
-
- spec/db/data-6.0/20171231235959_super_update.rb
|
253
|
-
- spec/db/data-6.0/20181128000207_excluded_file.rb.other_ext
|
254
248
|
- spec/db/data/20091231235959_some_name.rb
|
255
249
|
- spec/db/data/20171231235959_super_update.rb
|
256
250
|
- spec/db/data/20181128000207_excluded_file.rb.other_ext
|
@@ -258,10 +252,8 @@ files:
|
|
258
252
|
- spec/db/data/partial_schema/test_data_schema.rb
|
259
253
|
- spec/db/data/schema/data_schema.rb
|
260
254
|
- spec/db/data/schema/test_data_schema.rb
|
261
|
-
- spec/db/migrate/
|
262
|
-
- spec/db/migrate/
|
263
|
-
- spec/db/migrate/6.0/20131111111111_late_migration.rb
|
264
|
-
- spec/db/migrate/6.0/20202020202011_db_migration.rb
|
255
|
+
- spec/db/migrate/20131111111111_late_migration.rb
|
256
|
+
- spec/db/migrate/20202020202011_db_migration.rb
|
265
257
|
- spec/generators/data_migration/data_migration_generator_spec.rb
|
266
258
|
- spec/spec_helper.rb
|
267
259
|
- tasks/.gitkeep
|
@@ -270,13 +262,7 @@ homepage: https://github.com/ilyakatz/data-migrate
|
|
270
262
|
licenses:
|
271
263
|
- MIT
|
272
264
|
metadata: {}
|
273
|
-
post_install_message:
|
274
|
-
********************************************************************************
|
275
|
-
data-migrate: IMPORTANT: Breaking change introduced for migrations from v2.
|
276
|
-
|
277
|
-
Failure to run the migration can have serious consequences.
|
278
|
-
See Readme for more info.
|
279
|
-
********************************************************************************
|
265
|
+
post_install_message:
|
280
266
|
rdoc_options: []
|
281
267
|
require_paths:
|
282
268
|
- lib
|
@@ -291,7 +277,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
291
277
|
- !ruby/object:Gem::Version
|
292
278
|
version: '0'
|
293
279
|
requirements: []
|
294
|
-
rubygems_version: 3.
|
280
|
+
rubygems_version: 3.4.10
|
295
281
|
signing_key:
|
296
282
|
specification_version: 4
|
297
283
|
summary: Rake tasks to migrate data alongside schema changes.
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.7.5
|
data/.travis.yml
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
rvm:
|
3
|
-
- 2.7
|
4
|
-
- 3.0
|
5
|
-
script: bundle exec rspec
|
6
|
-
gemfile:
|
7
|
-
- gemfiles/rails_5.2.gemfile
|
8
|
-
- gemfiles/rails_6.0.gemfile
|
9
|
-
- gemfiles/rails_6.1.gemfile
|
10
|
-
- gemfiles/rails_7.0.gemfile
|
11
|
-
jobs:
|
12
|
-
exclude:
|
13
|
-
- rvm: 3.0
|
14
|
-
gemfile: gemfiles/rails_5.2.gemfile
|
data/Gemfile.rails5.2
DELETED
data/gemfiles/rails_5.2.gemfile
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
module DataMigrate
|
2
|
-
class LegacyMigrator
|
3
|
-
def initialize(migrations_paths = "db/data")
|
4
|
-
@migrations_paths = migrations_paths || "db/data"
|
5
|
-
end
|
6
|
-
|
7
|
-
def migrate
|
8
|
-
dates =
|
9
|
-
DataMigrate::DataMigrator.migrations(@migrations_paths).collect(&:version)
|
10
|
-
legacy = ActiveRecord::SchemaMigration.where(version: dates)
|
11
|
-
legacy.each do |v|
|
12
|
-
begin
|
13
|
-
version = v.version
|
14
|
-
puts "Creating #{version} in data schema"
|
15
|
-
DataMigrate::DataSchemaMigration.create(version: version)
|
16
|
-
rescue ActiveRecord::RecordNotUnique
|
17
|
-
nil
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module DataMigrate
|
2
|
-
# Helper class to getting access to db schema
|
3
|
-
# to allow data/schema combiation tasks
|
4
|
-
class SchemaMigration
|
5
|
-
def self.pending_schema_migrations
|
6
|
-
all_migrations = DataMigrate::MigrationContext.new(migrations_paths).migrations
|
7
|
-
sort_migrations(
|
8
|
-
ActiveRecord::Migrator.new(:up, all_migrations).
|
9
|
-
pending_migrations.
|
10
|
-
map {|m| { version: m.version, name: m.name, kind: :schema }}
|
11
|
-
)
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.run(direction, migration_paths, version)
|
15
|
-
ActiveRecord::MigrationContext.new(migration_paths).run(direction, version)
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.sort_migrations(set1, set2 = nil)
|
19
|
-
migrations = set1 + (set2 || [])
|
20
|
-
migrations.sort {|a, b| sort_string(a) <=> sort_string(b)}
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.migrations_paths
|
24
|
-
Rails.application.config.paths["db/migrate"].to_a
|
25
|
-
end
|
26
|
-
|
27
|
-
def self.sort_string(migration)
|
28
|
-
"#{migration[:version]}_#{migration[:kind] == :data ? 1 : 0}"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe DataMigrate::LegacyMigrator do
|
4
|
-
let(:context) {
|
5
|
-
DataMigrate::MigrationContext.new("spec/db/data")
|
6
|
-
}
|
7
|
-
|
8
|
-
after do
|
9
|
-
begin
|
10
|
-
ActiveRecord::Migration.drop_table("data_migrations")
|
11
|
-
ActiveRecord::Migration.drop_table("schema_migrations")
|
12
|
-
rescue StandardError
|
13
|
-
nil
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
before do
|
18
|
-
ActiveRecord::Base.establish_connection(db_config)
|
19
|
-
ActiveRecord::SchemaMigration.create_table
|
20
|
-
DataMigrate::DataSchemaMigration.create_table
|
21
|
-
end
|
22
|
-
|
23
|
-
let(:db_config) do
|
24
|
-
{
|
25
|
-
adapter: "sqlite3",
|
26
|
-
database: "spec/db/test.db"
|
27
|
-
}
|
28
|
-
end
|
29
|
-
|
30
|
-
it "migrate legacy migrations to be in correct table" do
|
31
|
-
DataMigrate::DataSchemaMigration.create_table
|
32
|
-
# simulate creation of legacy data migration when
|
33
|
-
# it was recorded in schema table
|
34
|
-
ActiveRecord::SchemaMigration.create(version: "20091231235959")
|
35
|
-
|
36
|
-
# create one migration in correct place
|
37
|
-
DataMigrate::DataSchemaMigration.create(version: "20171231235959")
|
38
|
-
|
39
|
-
migrated = DataMigrate::DataMigrator .new(:up, []).load_migrated
|
40
|
-
expect(migrated.count).to eq 1
|
41
|
-
|
42
|
-
DataMigrate::LegacyMigrator.new("spec/db/data").migrate
|
43
|
-
|
44
|
-
# after migacy migrator has been run, we should have records
|
45
|
-
# of both migrations
|
46
|
-
migrated = DataMigrate::DataMigrator .new(:up, []).load_migrated
|
47
|
-
expect(migrated.count).to eq 2
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
# This file should be excluded
|