data_migrate 10.0.3.rc → 11.0.0.rc

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/build.yml +4 -4
  3. data/.github/workflows/gempush.yml +6 -8
  4. data/.gitignore +0 -1
  5. data/Appraisals +10 -5
  6. data/Changelog.md +32 -6
  7. data/Gemfile +0 -1
  8. data/Gemfile.lock +188 -0
  9. data/README.md +13 -4
  10. data/data_migrate.gemspec +2 -2
  11. data/gemfiles/rails_6.1.gemfile +0 -1
  12. data/gemfiles/rails_6.1.gemfile.lock +233 -0
  13. data/gemfiles/rails_7.0.gemfile +1 -2
  14. data/gemfiles/rails_7.0.gemfile.lock +234 -0
  15. data/gemfiles/{rails_6.0.gemfile → rails_7.1.gemfile} +1 -2
  16. data/gemfiles/rails_7.1.gemfile.lock +266 -0
  17. data/gemfiles/rails_7.2.gemfile +7 -0
  18. data/gemfiles/rails_7.2.gemfile.lock +265 -0
  19. data/lib/data_migrate/data_migrator.rb +15 -23
  20. data/lib/data_migrate/data_schema.rb +2 -2
  21. data/lib/data_migrate/data_schema_migration.rb +24 -7
  22. data/lib/data_migrate/database_configurations_wrapper.rb +11 -0
  23. data/lib/data_migrate/database_tasks.rb +194 -48
  24. data/lib/data_migrate/migration_context.rb +11 -8
  25. data/lib/data_migrate/rails_helper.rb +90 -0
  26. data/lib/data_migrate/schema_dumper.rb +1 -1
  27. data/lib/data_migrate/schema_migration.rb +5 -4
  28. data/lib/data_migrate/status_service.rb +3 -3
  29. data/lib/data_migrate/tasks/data_migrate_tasks.rb +13 -14
  30. data/lib/data_migrate/test.rb +14 -0
  31. data/lib/data_migrate/version.rb +1 -1
  32. data/lib/data_migrate.rb +2 -1
  33. data/spec/data_migrate/data_migrator_spec.rb +17 -14
  34. data/spec/data_migrate/data_schema_migration_spec.rb +25 -8
  35. data/spec/data_migrate/data_spec.rb +1 -1
  36. data/spec/data_migrate/database_tasks_spec.rb +34 -19
  37. data/spec/data_migrate/migration_context_spec.rb +25 -9
  38. data/spec/data_migrate/schema_dumper_spec.rb +6 -3
  39. data/spec/data_migrate/schema_migration_spec.rb +13 -6
  40. data/spec/data_migrate/status_service_spec.rb +6 -3
  41. data/spec/data_migrate/tasks/data_migrate_tasks_spec.rb +13 -14
  42. data/spec/db/data/20091231235959_some_name.rb +1 -1
  43. data/spec/db/data/20171231235959_super_update.rb +1 -1
  44. data/spec/db/migrate/20131111111111_late_migration.rb +1 -1
  45. data/spec/db/migrate/20202020202011_db_migration.rb +1 -1
  46. data/tasks/databases.rake +25 -93
  47. metadata +21 -15
  48. data/Gemfile.rails6.1 +0 -11
  49. data/lib/data_migrate/legacy_migrator.rb +0 -22
  50. data/spec/data_migrate/legacy_migrator_spec.rb +0 -38
@@ -8,10 +8,17 @@ describe DataMigrate::SchemaMigration do
8
8
  let(:fixture_file_timestamps) do
9
9
  %w[20091231235959 20101231235959 20111231235959]
10
10
  end
11
+ let(:db_config) do
12
+ {
13
+ adapter: "sqlite3",
14
+ database: "spec/db/test.db"
15
+ }
16
+ end
11
17
 
12
18
  before do
13
- ActiveRecord::SchemaMigration.create_table
14
- DataMigrate::DataSchemaMigration.create_table
19
+ ActiveRecord::Base.establish_connection(db_config)
20
+ DataMigrate::RailsHelper.schema_migration.create_table
21
+ DataMigrate::RailsHelper.data_schema_migration.create_table
15
22
  end
16
23
 
17
24
  after do
@@ -38,7 +45,7 @@ describe DataMigrate::SchemaMigration do
38
45
  expect {
39
46
  subject.run(:up, migration_path, 20202020202011)
40
47
  }.to output(/20202020202011 DbMigration: migrating/).to_stdout
41
- versions = ActiveRecord::SchemaMigration.normalized_versions
48
+ versions = DataMigrate::RailsHelper.schema_migration.normalized_versions
42
49
  expect(versions.first).to eq("20202020202011")
43
50
  end
44
51
 
@@ -49,7 +56,7 @@ describe DataMigrate::SchemaMigration do
49
56
  subject.run(:down, migration_path, 20202020202011)
50
57
  }.to output(/Undoing DbMigration/).to_stdout
51
58
 
52
- versions = ActiveRecord::SchemaMigration.normalized_versions
59
+ versions = DataMigrate::RailsHelper.schema_migration.normalized_versions
53
60
 
54
61
  expect(versions.count).to eq(0)
55
62
  end
@@ -61,9 +68,9 @@ describe DataMigrate::SchemaMigration do
61
68
  let(:paths) { ['spec/db/migrate', 'spec/db/migrate/other'] }
62
69
  let(:specification_name) { "primary" }
63
70
  let(:config_options) do
64
- if Gem::Dependency.new("railties", "~> 6.0").match?("railties", Gem.loaded_specs["railties"].version)
71
+ if Gem::Dependency.new("railties", "~> 6.1").match?("railties", Gem.loaded_specs["railties"].version)
65
72
  { env_name: Rails.env, spec_name: specification_name }
66
- elsif Gem::Dependency.new("railties", "~> 7.0").match?("railties", Gem.loaded_specs["railties"].version)
73
+ else
67
74
  { env_name: Rails.env, name: specification_name }
68
75
  end
69
76
  end
@@ -33,9 +33,12 @@ describe DataMigrate::StatusService do
33
33
  end
34
34
 
35
35
  before do
36
- ActiveRecord::SchemaMigration.create_table
37
- DataMigrate::DataSchemaMigration.create_table
38
- DataMigrate::DataSchemaMigration.create(fixture_file_timestamps.map { |t| { version: t } })
36
+ DataMigrate::RailsHelper.schema_migration.create_table
37
+ DataMigrate::RailsHelper.data_schema_migration.create_table
38
+
39
+ fixture_file_timestamps.map do |t|
40
+ DataMigrate::RailsHelper.data_schema_migration.create_version(t)
41
+ end
39
42
 
40
43
  subject.dump(connection_db_config, stream)
41
44
  stream.rewind
@@ -3,17 +3,17 @@
3
3
  require "spec_helper"
4
4
 
5
5
  describe DataMigrate::Tasks::DataMigrateTasks do
6
- let(:connection_db_config) do
7
- if Gem::Dependency.new("railties", ">= 6.1").match?("railties", Gem.loaded_specs["railties"].version)
8
- ActiveRecord::Base.connection_db_config
9
- else
10
- ActiveRecord::Base.configurations.configs_for.first
11
- end
6
+ let(:db_config) do
7
+ {
8
+ adapter: "sqlite3",
9
+ database: "spec/db/test.db"
10
+ }
12
11
  end
13
12
 
14
13
  before do
15
- ActiveRecord::SchemaMigration.create_table
16
- DataMigrate::DataSchemaMigration.create_table
14
+ ActiveRecord::Base.establish_connection(db_config)
15
+ DataMigrate::RailsHelper.schema_migration.create_table
16
+ DataMigrate::RailsHelper.data_schema_migration.create_table
17
17
  end
18
18
 
19
19
  after do
@@ -28,11 +28,11 @@ describe DataMigrate::Tasks::DataMigrateTasks do
28
28
  end
29
29
 
30
30
  context 'when not given a separate db config' do
31
- it 'does not override the default connection' do
31
+ it 'does not override the default connection' do
32
32
  expect(ActiveRecord::Base).not_to receive(:establish_connection)
33
33
  expect(DataMigrate::SchemaDumper).to receive(:dump)
34
34
 
35
- DataMigrate::Tasks::DataMigrateTasks.dump(connection_db_config)
35
+ DataMigrate::Tasks::DataMigrateTasks.dump
36
36
  end
37
37
  end
38
38
 
@@ -56,8 +56,7 @@ describe DataMigrate::Tasks::DataMigrateTasks do
56
56
 
57
57
  it 'overrides the default connection' do
58
58
  expect(ActiveRecord::Base).to receive(:establish_connection).with(override_config)
59
-
60
- DataMigrate::Tasks::DataMigrateTasks.dump(connection_db_config)
59
+ DataMigrate::Tasks::DataMigrateTasks.dump
61
60
  end
62
61
  end
63
62
  end
@@ -116,13 +115,13 @@ describe DataMigrate::Tasks::DataMigrateTasks do
116
115
 
117
116
  it "should display data migration status" do
118
117
  expect {
119
- DataMigrate::Tasks::DataMigrateTasks.status(connection_db_config)
118
+ DataMigrate::Tasks::DataMigrateTasks.status
120
119
  }.to output(/up 20091231235959 Some name/).to_stdout
121
120
  end
122
121
 
123
122
  it "should display schema and data migration status" do
124
123
  expect {
125
- DataMigrate::Tasks::DataMigrateTasks.status_with_schema(connection_db_config)
124
+ DataMigrate::Tasks::DataMigrateTasks.status_with_schema
126
125
  }.to output(match(/up data 20091231235959 Some name/)
127
126
  .and match(/down schema 20131111111111 Late migration/)).to_stdout
128
127
  end
@@ -1,4 +1,4 @@
1
- class SomeName < ActiveRecord::Migration[6.0]
1
+ class SomeName < ActiveRecord::Migration[6.1]
2
2
  def up
3
3
  puts "Doing data migration"
4
4
  end
@@ -1,4 +1,4 @@
1
- class SuperUpdate < ActiveRecord::Migration[6.0]
1
+ class SuperUpdate < ActiveRecord::Migration[6.1]
2
2
  def up
3
3
  puts "Doing SuperUpdate"
4
4
  end
@@ -1,4 +1,4 @@
1
- class LateMigration < ActiveRecord::Migration[6.0]
1
+ class LateMigration < ActiveRecord::Migration[6.1]
2
2
  def up
3
3
  puts "Doing schema LateMigration"
4
4
  end
@@ -1,4 +1,4 @@
1
- class DbMigration < ActiveRecord::Migration[6.0]
1
+ class DbMigration < ActiveRecord::Migration[6.1]
2
2
  def up
3
3
  puts "Doing schema migration"
4
4
  end
data/tasks/databases.rake CHANGED
@@ -5,71 +5,16 @@ 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
- original_db_config = if Gem::Dependency.new("railties", "~> 7.0").match?("railties", Gem.loaded_specs["railties"].version)
10
- ActiveRecord::Base.connection_db_config
11
- elsif Gem::Dependency.new("railties", "~> 6.0").match?("railties", Gem.loaded_specs["railties"].version)
12
- ActiveRecord::Base.connection_config
13
- end
14
-
15
- ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config|
16
- ActiveRecord::Base.establish_connection(db_config)
17
- DataMigrate::DataMigrator.assure_data_schema_table
18
-
19
- ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
20
- target_version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
21
- migrations = []
22
-
23
- if target_version.nil?
24
- migrations = DataMigrate::DatabaseTasks.pending_migrations.map{ |m| m.merge(:direction =>:up) }
25
- else
26
- current_schema_version = ActiveRecord::Migrator.current_version
27
- schema_migrations = if target_version > current_schema_version
28
- DataMigrate::DatabaseTasks.pending_schema_migrations.keep_if{ |m| m[:version] <= target_version }.map{ |m| m.merge(:direction =>:up) }
29
- elsif target_version < current_schema_version
30
- DataMigrate::DatabaseTasks.past_migrations.keep_if{ |m| m[:version] > target_version }.map{ |m| m.merge(:direction =>:down) }
31
- else # ==
32
- []
33
- end
34
-
35
- current_data_version = DataMigrate::DataMigrator.current_version
36
- data_migrations = if target_version > current_data_version
37
- DataMigrate::DatabaseTasks.pending_data_migrations.keep_if{ |m| m[:version] <= target_version }.map{ |m| m.merge(:direction =>:up) }
38
- elsif target_version < current_data_version
39
- DataMigrate::DatabaseTasks.past_migrations.keep_if{ |m| m[:version] > target_version }.map{ |m| m.merge(:direction =>:down) }
40
- else # ==
41
- []
42
- end
43
- migrations = if schema_migrations.empty?
44
- data_migrations
45
- elsif data_migrations.empty?
46
- schema_migrations
47
- elsif target_version > current_data_version && target_version > current_schema_version
48
- DataMigrate::DatabaseTasks.sort_migrations data_migrations, schema_migrations
49
- elsif target_version < current_data_version && target_version < current_schema_version
50
- DataMigrate::DatabaseTasks.sort_migrations(data_migrations, schema_migrations).reverse
51
- elsif target_version > current_data_version && target_version < current_schema_version
52
- schema_migrations + data_migrations
53
- elsif target_version < current_data_version && target_version > current_schema_version
54
- schema_migrations + data_migrations
55
- end
56
- end
57
-
58
- migrations.each do |migration|
59
- DataMigrate::DatabaseTasks.run_migration(migration, migration[:direction])
60
- end
61
- end
62
-
8
+ task :with_data => :load_config do
9
+ DataMigrate::DatabaseTasks.migrate_with_data
63
10
  Rake::Task["db:_dump"].invoke
64
11
  Rake::Task["data:dump"].invoke
65
- ensure
66
- ActiveRecord::Base.establish_connection(original_db_config)
67
12
  end
68
13
 
69
14
  namespace :redo do
70
15
  desc 'Rollbacks the database one migration and re migrate up (options: STEP=x, VERSION=x).'
71
16
  task :with_data => :environment do
72
- DataMigrate::DataMigrator.assure_data_schema_table
17
+ DataMigrate::DataMigrator.create_data_schema_table
73
18
  if ENV["VERSION"]
74
19
  Rake::Task["db:migrate:down:with_data"].invoke
75
20
  Rake::Task["db:migrate:up:with_data"].invoke
@@ -85,7 +30,7 @@ namespace :db do
85
30
  task :with_data => :environment do
86
31
  version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
87
32
  raise "VERSION is required" unless version
88
- DataMigrate::DataMigrator.assure_data_schema_table
33
+ DataMigrate::DataMigrator.create_data_schema_table
89
34
  run_both = ENV["BOTH"] == "true"
90
35
  migrations = DataMigrate::DatabaseTasks.pending_migrations.keep_if{|m| m[:version] == version}
91
36
 
@@ -107,7 +52,7 @@ namespace :db do
107
52
  task :with_data => :environment do
108
53
  version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
109
54
  raise "VERSION is required" unless version
110
- DataMigrate::DataMigrator.assure_data_schema_table
55
+ DataMigrate::DataMigrator.create_data_schema_table
111
56
  run_both = ENV["BOTH"] == "true"
112
57
  migrations = DataMigrate::DatabaseTasks.past_migrations.keep_if{|m| m[:version] == version}
113
58
 
@@ -127,10 +72,7 @@ namespace :db do
127
72
  namespace :status do
128
73
  desc "Display status of data and schema migrations"
129
74
  task :with_data => :environment do
130
- ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config|
131
- ActiveRecord::Base.establish_connection(db_config)
132
- DataMigrate::Tasks::DataMigrateTasks.status_with_schema(db_config)
133
- end
75
+ DataMigrate::Tasks::DataMigrateTasks.status_with_schema
134
76
  end
135
77
  end
136
78
  end # END OF MIGRATE NAME SPACE
@@ -139,7 +81,7 @@ namespace :db do
139
81
  desc 'Rolls the schema back to the previous version (specify steps w/ STEP=n).'
140
82
  task :with_data => :environment do
141
83
  step = ENV['STEP'] ? ENV['STEP'].to_i : 1
142
- DataMigrate::DataMigrator.assure_data_schema_table
84
+ DataMigrate::DataMigrator.create_data_schema_table
143
85
  DataMigrate::DatabaseTasks.past_migrations[0..(step - 1)].each do | past_migration |
144
86
  DataMigrate::DatabaseTasks.run_migration(past_migration, :down)
145
87
  end
@@ -152,7 +94,7 @@ namespace :db do
152
94
  namespace :forward do
153
95
  desc 'Pushes the schema to the next version (specify steps w/ STEP=n).'
154
96
  task :with_data => :environment do
155
- DataMigrate::DataMigrator.assure_data_schema_table
97
+ DataMigrate::DataMigrator.create_data_schema_table
156
98
  step = ENV['STEP'] ? ENV['STEP'].to_i : 1
157
99
  DataMigrate::DatabaseTasks.forward(step)
158
100
  Rake::Task["db:_dump"].invoke
@@ -163,7 +105,7 @@ namespace :db do
163
105
  namespace :version do
164
106
  desc "Retrieves the current schema version numbers for data and schema migrations"
165
107
  task :with_data => :environment do
166
- DataMigrate::DataMigrator.assure_data_schema_table
108
+ DataMigrate::DataMigrator.create_data_schema_table
167
109
  puts "Current Schema version: #{ActiveRecord::Migrator.current_version}"
168
110
  puts "Current Data version: #{DataMigrate::DataMigrator.current_version}"
169
111
  end
@@ -204,30 +146,26 @@ namespace :db do
204
146
  end
205
147
  end
206
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
207
156
  end
208
157
 
209
158
  namespace :data do
210
159
  desc 'Migrate data migrations (options: VERSION=x, VERBOSE=false)'
211
160
  task :migrate => :environment do
212
- original_db_config = if Gem::Dependency.new("railties", "~> 7.0").match?("railties", Gem.loaded_specs["railties"].version)
213
- ActiveRecord::Base.connection_db_config
214
- elsif Gem::Dependency.new("railties", "~> 6.0").match?("railties", Gem.loaded_specs["railties"].version)
215
- ActiveRecord::Base.connection_config
216
- end
217
-
218
- ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config|
219
- ActiveRecord::Base.establish_connection(db_config)
220
- DataMigrate::Tasks::DataMigrateTasks.migrate
221
- end
161
+ DataMigrate::Tasks::DataMigrateTasks.migrate
222
162
  Rake::Task["data:dump"].invoke
223
- ensure
224
- ActiveRecord::Base.establish_connection(original_db_config)
225
163
  end
226
164
 
227
165
  namespace :migrate do
228
166
  desc 'Rollbacks the database one migration and re migrate up (options: STEP=x, VERSION=x).'
229
167
  task :redo => :environment do
230
- DataMigrate::DataMigrator.assure_data_schema_table
168
+ DataMigrate::DataMigrator.create_data_schema_table
231
169
  if ENV["VERSION"]
232
170
  Rake::Task["data:migrate:down"].invoke
233
171
  Rake::Task["data:migrate:up"].invoke
@@ -239,7 +177,7 @@ namespace :data do
239
177
 
240
178
  desc 'Runs the "up" for a given migration VERSION.'
241
179
  task :up => :environment do
242
- DataMigrate::DataMigrator.assure_data_schema_table
180
+ DataMigrate::DataMigrator.create_data_schema_table
243
181
  version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
244
182
  raise "VERSION is required" unless version
245
183
  DataMigrate::DataMigrator.run(:up, DataMigrate::DatabaseTasks.data_migrations_path, version)
@@ -250,23 +188,20 @@ namespace :data do
250
188
  task :down => :environment do
251
189
  version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
252
190
  raise "VERSION is required" unless version
253
- DataMigrate::DataMigrator.assure_data_schema_table
191
+ DataMigrate::DataMigrator.create_data_schema_table
254
192
  DataMigrate::DataMigrator.run(:down, DataMigrate::DatabaseTasks.data_migrations_path, version)
255
193
  Rake::Task["data:dump"].invoke
256
194
  end
257
195
 
258
196
  desc "Display status of data migrations"
259
197
  task :status => :environment do
260
- ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config|
261
- ActiveRecord::Base.establish_connection(db_config)
262
- DataMigrate::Tasks::DataMigrateTasks.status(db_config)
263
- end
198
+ DataMigrate::Tasks::DataMigrateTasks.status
264
199
  end
265
200
  end
266
201
 
267
202
  desc 'Rolls the schema back to the previous version (specify steps w/ STEP=n).'
268
203
  task :rollback => :environment do
269
- DataMigrate::DataMigrator.assure_data_schema_table
204
+ DataMigrate::DataMigrator.create_data_schema_table
270
205
  step = ENV['STEP'] ? ENV['STEP'].to_i : 1
271
206
  DataMigrate::DataMigrator.rollback(DataMigrate::DatabaseTasks.data_migrations_path, step)
272
207
  Rake::Task["data:dump"].invoke
@@ -274,7 +209,7 @@ namespace :data do
274
209
 
275
210
  desc 'Pushes the schema to the next version (specify steps w/ STEP=n).'
276
211
  task :forward => :environment do
277
- DataMigrate::DataMigrator.assure_data_schema_table
212
+ DataMigrate::DataMigrator.create_data_schema_table
278
213
  step = ENV['STEP'] ? ENV['STEP'].to_i : 1
279
214
  # TODO: No worky for .forward
280
215
  # DataMigrate::DataMigrator.forward('db/data/', step)
@@ -287,7 +222,7 @@ namespace :data do
287
222
 
288
223
  desc "Retrieves the current schema version number for data migrations"
289
224
  task :version => :environment do
290
- DataMigrate::DataMigrator.assure_data_schema_table
225
+ DataMigrate::DataMigrator.create_data_schema_table
291
226
  puts "Current data version: #{DataMigrate::DataMigrator.current_version}"
292
227
  end
293
228
 
@@ -299,10 +234,7 @@ namespace :data do
299
234
 
300
235
  desc "Create a db/data_schema.rb file that stores the current data version"
301
236
  task dump: :environment do
302
- ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config|
303
- ActiveRecord::Base.establish_connection(db_config)
304
- DataMigrate::Tasks::DataMigrateTasks.dump(db_config)
305
- end
237
+ DataMigrate::Tasks::DataMigrateTasks.dump
306
238
 
307
239
  # Allow this task to be called as many times as required. An example
308
240
  # is the migrate:redo task, which calls other two internally
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: 10.0.3.rc
4
+ version: 11.0.0.rc
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-06-15 00:00:00.000000000 Z
13
+ date: 2024-08-20 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: '6.0'
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: '6.0'
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: '6.0'
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: '6.0'
42
+ version: '6.1'
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: appraisal
45
45
  requirement: !ruby/object:Gem::Requirement
@@ -128,16 +128,16 @@ dependencies:
128
128
  name: sqlite3
129
129
  requirement: !ruby/object:Gem::Requirement
130
130
  requirements:
131
- - - "~>"
131
+ - - ">="
132
132
  - !ruby/object:Gem::Version
133
- version: 1.3.6
133
+ version: '0'
134
134
  type: :development
135
135
  prerelease: false
136
136
  version_requirements: !ruby/object:Gem::Requirement
137
137
  requirements:
138
- - - "~>"
138
+ - - ">="
139
139
  - !ruby/object:Gem::Version
140
- version: 1.3.6
140
+ version: '0'
141
141
  - !ruby/object:Gem::Dependency
142
142
  name: timecop
143
143
  requirement: !ruby/object:Gem::Requirement
@@ -201,14 +201,19 @@ files:
201
201
  - Appraisals
202
202
  - Changelog.md
203
203
  - Gemfile
204
- - Gemfile.rails6.1
204
+ - Gemfile.lock
205
205
  - LICENSE
206
206
  - README.md
207
207
  - Rakefile
208
208
  - data_migrate.gemspec
209
- - gemfiles/rails_6.0.gemfile
210
209
  - gemfiles/rails_6.1.gemfile
210
+ - gemfiles/rails_6.1.gemfile.lock
211
211
  - gemfiles/rails_7.0.gemfile
212
+ - gemfiles/rails_7.0.gemfile.lock
213
+ - gemfiles/rails_7.1.gemfile
214
+ - gemfiles/rails_7.1.gemfile.lock
215
+ - gemfiles/rails_7.2.gemfile
216
+ - gemfiles/rails_7.2.gemfile.lock
212
217
  - lib/capistrano/data_migrate.rb
213
218
  - lib/capistrano/data_migrate/migrate.rb
214
219
  - lib/data_migrate.rb
@@ -216,14 +221,16 @@ files:
216
221
  - lib/data_migrate/data_migrator.rb
217
222
  - lib/data_migrate/data_schema.rb
218
223
  - lib/data_migrate/data_schema_migration.rb
224
+ - lib/data_migrate/database_configurations_wrapper.rb
219
225
  - lib/data_migrate/database_tasks.rb
220
- - lib/data_migrate/legacy_migrator.rb
221
226
  - lib/data_migrate/migration_context.rb
227
+ - lib/data_migrate/rails_helper.rb
222
228
  - lib/data_migrate/railtie.rb
223
229
  - lib/data_migrate/schema_dumper.rb
224
230
  - lib/data_migrate/schema_migration.rb
225
231
  - lib/data_migrate/status_service.rb
226
232
  - lib/data_migrate/tasks/data_migrate_tasks.rb
233
+ - lib/data_migrate/test.rb
227
234
  - lib/data_migrate/version.rb
228
235
  - lib/generators/data_migrate.rb
229
236
  - lib/generators/data_migration/data_migration_generator.rb
@@ -235,7 +242,6 @@ files:
235
242
  - spec/data_migrate/data_schema_migration_spec.rb
236
243
  - spec/data_migrate/data_spec.rb
237
244
  - spec/data_migrate/database_tasks_spec.rb
238
- - spec/data_migrate/legacy_migrator_spec.rb
239
245
  - spec/data_migrate/migration.rb
240
246
  - spec/data_migrate/migration_context_spec.rb
241
247
  - spec/data_migrate/schema_dumper_spec.rb
@@ -274,7 +280,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
274
280
  - !ruby/object:Gem::Version
275
281
  version: 1.3.1
276
282
  requirements: []
277
- rubygems_version: 3.3.26
283
+ rubygems_version: 3.4.19
278
284
  signing_key:
279
285
  specification_version: 4
280
286
  summary: Rake tasks to migrate data alongside schema changes.
data/Gemfile.rails6.1 DELETED
@@ -1,11 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- # Specify your gem's dependencies in data_migrate.gemspec
4
- %w[
5
- activerecord
6
- railties
7
- ].each do |rails_gem|
8
- gem rails_gem, '~> 6.1.0'
9
- end
10
- gem 'sqlite3', "~> 1.4"
11
- gemspec
@@ -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,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
-
5
- describe DataMigrate::LegacyMigrator do
6
- let(:context) {
7
- DataMigrate::MigrationContext.new("spec/db/data")
8
- }
9
-
10
- before do
11
- ActiveRecord::SchemaMigration.create_table
12
- DataMigrate::DataSchemaMigration.create_table
13
- end
14
-
15
- after do
16
- ActiveRecord::Migration.drop_table("data_migrations") rescue nil
17
- ActiveRecord::Migration.drop_table("schema_migrations") rescue nil
18
- end
19
-
20
- it "migrate legacy migrations to be in correct table" do
21
- # simulate creation of legacy data migration when
22
- # it was recorded in schema table
23
- ActiveRecord::SchemaMigration.create(version: "20091231235959")
24
-
25
- # create one migration in correct place
26
- DataMigrate::DataSchemaMigration.create(version: "20171231235959")
27
-
28
- migrated = DataMigrate::DataMigrator.new(:up, []).load_migrated
29
- expect(migrated.count).to eq 1
30
-
31
- DataMigrate::LegacyMigrator.new("spec/db/data").migrate
32
-
33
- # after migacy migrator has been run, we should have records
34
- # of both migrations
35
- migrated = DataMigrate::DataMigrator .new(:up, []).load_migrated
36
- expect(migrated.count).to eq 2
37
- end
38
- end