data_migrate 9.4.0 → 10.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +3 -3
- data/.github/workflows/gempush.yml +8 -6
- data/.gitignore +2 -3
- data/.ruby-version +1 -0
- data/.travis.yml +14 -0
- data/Appraisals +5 -5
- data/Changelog.md +2 -40
- data/Gemfile +1 -0
- data/Gemfile.rails6.1 +11 -0
- data/README.md +5 -7
- data/data_migrate.gemspec +2 -2
- data/gemfiles/{rails_7.1.gemfile → rails_6.0.gemfile} +2 -1
- data/gemfiles/rails_6.1.gemfile +1 -0
- data/gemfiles/rails_7.0.gemfile +2 -1
- data/lib/data_migrate/data_migrator.rb +23 -15
- data/lib/data_migrate/data_schema.rb +2 -2
- data/lib/data_migrate/data_schema_migration.rb +7 -24
- data/lib/data_migrate/database_tasks.rb +48 -126
- data/lib/data_migrate/legacy_migrator.rb +22 -0
- data/lib/data_migrate/migration_context.rb +8 -11
- data/lib/data_migrate/schema_dumper.rb +1 -1
- data/lib/data_migrate/schema_migration.rb +4 -5
- data/lib/data_migrate/status_service.rb +4 -4
- data/lib/data_migrate/tasks/data_migrate_tasks.rb +15 -14
- data/lib/data_migrate/version.rb +1 -1
- data/lib/data_migrate.rb +1 -2
- data/spec/data_migrate/data_migrator_spec.rb +14 -17
- data/spec/data_migrate/data_schema_migration_spec.rb +8 -25
- data/spec/data_migrate/data_spec.rb +1 -1
- data/spec/data_migrate/database_tasks_spec.rb +19 -34
- data/spec/data_migrate/legacy_migrator_spec.rb +38 -0
- data/spec/data_migrate/migration_context_spec.rb +8 -15
- data/spec/data_migrate/schema_dumper_spec.rb +3 -6
- data/spec/data_migrate/schema_migration_spec.rb +6 -13
- data/spec/data_migrate/status_service_spec.rb +4 -7
- data/spec/data_migrate/tasks/data_migrate_tasks_spec.rb +14 -13
- data/spec/db/data/20091231235959_some_name.rb +1 -1
- data/spec/db/data/20171231235959_super_update.rb +1 -1
- data/spec/db/migrate/20131111111111_late_migration.rb +1 -1
- data/spec/db/migrate/20202020202011_db_migration.rb +1 -1
- data/tasks/databases.rake +77 -39
- metadata +19 -21
- data/Gemfile.lock +0 -184
- data/gemfiles/rails_6.1.gemfile.lock +0 -229
- data/gemfiles/rails_7.0.gemfile.lock +0 -230
- data/gemfiles/rails_7.1.gemfile.lock +0 -263
- data/lib/data_migrate/database_configurations_wrapper.rb +0 -11
- data/lib/data_migrate/rails_helper.rb +0 -79
- data/lib/data_migrate/test.rb +0 -14
@@ -1,11 +0,0 @@
|
|
1
|
-
module DataMigrate
|
2
|
-
# This wrapper is used to differentiate between
|
3
|
-
# a data and schema db config when running migrations
|
4
|
-
class DatabaseConfigurationWrapper
|
5
|
-
attr_reader :db_config
|
6
|
-
|
7
|
-
def initialize(db_config)
|
8
|
-
@db_config = db_config
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
@@ -1,79 +0,0 @@
|
|
1
|
-
module DataMigrate
|
2
|
-
class RailsHelper
|
3
|
-
class << self
|
4
|
-
def rails_version_equal_to_or_higher_than_7_1
|
5
|
-
return @equal_to_or_higher_than_7_1 if defined?(@equal_to_or_higher_than_7_1)
|
6
|
-
|
7
|
-
@equal_to_or_higher_than_7_1 = Gem::Dependency.new("railties", ">= 7.1.0.alpha").match?("railties", Gem.loaded_specs["railties"].version, true)
|
8
|
-
end
|
9
|
-
|
10
|
-
def rails_version_equal_to_or_higher_than_7_0
|
11
|
-
return @rails_version_equal_to_or_higher_than_7_0 if defined?(@rails_version_equal_to_or_higher_than_7_0)
|
12
|
-
|
13
|
-
@rails_version_equal_to_or_higher_than_7_0 = Gem::Dependency.new("railties", ">= 7.0").match?("railties", Gem.loaded_specs["railties"].version, true)
|
14
|
-
end
|
15
|
-
|
16
|
-
def internal_metadata
|
17
|
-
if rails_version_equal_to_or_higher_than_7_1
|
18
|
-
ActiveRecord::Base.connection.internal_metadata
|
19
|
-
else
|
20
|
-
ActiveRecord::InternalMetadata
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def schema_migration
|
25
|
-
if rails_version_equal_to_or_higher_than_7_1
|
26
|
-
ActiveRecord::Base.connection.schema_migration
|
27
|
-
else
|
28
|
-
ActiveRecord::SchemaMigration
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def schema_migration_versions
|
33
|
-
if rails_version_equal_to_or_higher_than_7_1
|
34
|
-
schema_migration.versions
|
35
|
-
else
|
36
|
-
schema_migration.all.pluck(:version)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def schema_create_version(version)
|
41
|
-
if rails_version_equal_to_or_higher_than_7_1
|
42
|
-
schema_migration.create_version(version)
|
43
|
-
else
|
44
|
-
schema_migration.create(version: version)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def data_schema_delete_version(version)
|
49
|
-
if rails_version_equal_to_or_higher_than_7_1
|
50
|
-
data_schema_migration.delete_version(version)
|
51
|
-
else
|
52
|
-
data_schema_migration.where(version: version.to_s).delete_all
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def data_schema_migration
|
57
|
-
if rails_version_equal_to_or_higher_than_7_1
|
58
|
-
DataMigrate::DataSchemaMigration.new(ActiveRecord::Tasks::DatabaseTasks.migration_connection)
|
59
|
-
else
|
60
|
-
DataMigrate::DataSchemaMigration
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def data_migrator(
|
65
|
-
direction,
|
66
|
-
migrations,
|
67
|
-
schema_migration = DataMigrate::RailsHelper.schema_migration,
|
68
|
-
internal_metadata = DataMigrate::RailsHelper.internal_metadata,
|
69
|
-
target_version = nil
|
70
|
-
)
|
71
|
-
if rails_version_equal_to_or_higher_than_7_1
|
72
|
-
DataMigrate::DataMigrator.new(direction, migrations, schema_migration, internal_metadata, target_version)
|
73
|
-
else
|
74
|
-
DataMigrate::DataMigrator.new(direction, migrations, schema_migration, target_version)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|