data_migrate 10.0.0.rc1 → 11.0.0.rc

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) 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 +3 -2
  5. data/Appraisals +10 -5
  6. data/Changelog.md +51 -2
  7. data/Gemfile +0 -1
  8. data/Gemfile.lock +188 -0
  9. data/README.md +17 -6
  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 +4 -4
  29. data/lib/data_migrate/tasks/data_migrate_tasks.rb +14 -15
  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 +7 -4
  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 -83
  47. metadata +21 -17
  48. data/.ruby-version +0 -1
  49. data/.travis.yml +0 -14
  50. data/Gemfile.rails6.1 +0 -11
  51. data/lib/data_migrate/legacy_migrator.rb +0 -22
  52. 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("rails", "~> 6.0").match?("rails", Gem.loaded_specs["rails"].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("rails", "~> 7.0").match?("rails", Gem.loaded_specs["rails"].version)
73
+ else
67
74
  { env_name: Rails.env, name: specification_name }
68
75
  end
69
76
  end
@@ -7,7 +7,7 @@ describe DataMigrate::StatusService do
7
7
  let(:stream) { StringIO.new }
8
8
  let(:stream_data) { stream.read }
9
9
  let(:connection_db_config) do
10
- if Gem::Dependency.new("rails", ">= 6.1").match?("rails", Gem.loaded_specs["rails"].version)
10
+ if Gem::Dependency.new("railties", ">= 6.1").match?("railties", Gem.loaded_specs["railties"].version)
11
11
  ActiveRecord::Base.connection_db_config
12
12
  else
13
13
  ActiveRecord::Base.configurations.configs_for.first
@@ -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("rails", ">= 6.1").match?("rails", Gem.loaded_specs["rails"].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,66 +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 = ActiveRecord::Base.connection_db_config
10
- ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config|
11
- ActiveRecord::Base.establish_connection(db_config)
12
- DataMigrate::DataMigrator.assure_data_schema_table
13
-
14
- ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
15
- target_version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
16
- migrations = []
17
-
18
- if target_version.nil?
19
- migrations = DataMigrate::DatabaseTasks.pending_migrations.map{ |m| m.merge(:direction =>:up) }
20
- else
21
- current_schema_version = ActiveRecord::Migrator.current_version
22
- schema_migrations = if target_version > current_schema_version
23
- DataMigrate::DatabaseTasks.pending_schema_migrations.keep_if{ |m| m[:version] <= target_version }.map{ |m| m.merge(:direction =>:up) }
24
- elsif target_version < current_schema_version
25
- DataMigrate::DatabaseTasks.past_migrations.keep_if{ |m| m[:version] > target_version }.map{ |m| m.merge(:direction =>:down) }
26
- else # ==
27
- []
28
- end
29
-
30
- current_data_version = DataMigrate::DataMigrator.current_version
31
- data_migrations = if target_version > current_data_version
32
- DataMigrate::DatabaseTasks.pending_data_migrations.keep_if{ |m| m[:version] <= target_version }.map{ |m| m.merge(:direction =>:up) }
33
- elsif target_version < current_data_version
34
- DataMigrate::DatabaseTasks.past_migrations.keep_if{ |m| m[:version] > target_version }.map{ |m| m.merge(:direction =>:down) }
35
- else # ==
36
- []
37
- end
38
- migrations = if schema_migrations.empty?
39
- data_migrations
40
- elsif data_migrations.empty?
41
- schema_migrations
42
- elsif target_version > current_data_version && target_version > current_schema_version
43
- DataMigrate::DatabaseTasks.sort_migrations data_migrations, schema_migrations
44
- elsif target_version < current_data_version && target_version < current_schema_version
45
- DataMigrate::DatabaseTasks.sort_migrations(data_migrations, schema_migrations).reverse
46
- elsif target_version > current_data_version && target_version < current_schema_version
47
- schema_migrations + data_migrations
48
- elsif target_version < current_data_version && target_version > current_schema_version
49
- schema_migrations + data_migrations
50
- end
51
- end
52
-
53
- migrations.each do |migration|
54
- DataMigrate::DatabaseTasks.run_migration(migration, migration[:direction])
55
- end
56
- end
57
-
8
+ task :with_data => :load_config do
9
+ DataMigrate::DatabaseTasks.migrate_with_data
58
10
  Rake::Task["db:_dump"].invoke
59
11
  Rake::Task["data:dump"].invoke
60
- ensure
61
- ActiveRecord::Base.establish_connection(original_db_config)
62
12
  end
63
13
 
64
14
  namespace :redo do
65
15
  desc 'Rollbacks the database one migration and re migrate up (options: STEP=x, VERSION=x).'
66
16
  task :with_data => :environment do
67
- DataMigrate::DataMigrator.assure_data_schema_table
17
+ DataMigrate::DataMigrator.create_data_schema_table
68
18
  if ENV["VERSION"]
69
19
  Rake::Task["db:migrate:down:with_data"].invoke
70
20
  Rake::Task["db:migrate:up:with_data"].invoke
@@ -80,7 +30,7 @@ namespace :db do
80
30
  task :with_data => :environment do
81
31
  version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
82
32
  raise "VERSION is required" unless version
83
- DataMigrate::DataMigrator.assure_data_schema_table
33
+ DataMigrate::DataMigrator.create_data_schema_table
84
34
  run_both = ENV["BOTH"] == "true"
85
35
  migrations = DataMigrate::DatabaseTasks.pending_migrations.keep_if{|m| m[:version] == version}
86
36
 
@@ -102,7 +52,7 @@ namespace :db do
102
52
  task :with_data => :environment do
103
53
  version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
104
54
  raise "VERSION is required" unless version
105
- DataMigrate::DataMigrator.assure_data_schema_table
55
+ DataMigrate::DataMigrator.create_data_schema_table
106
56
  run_both = ENV["BOTH"] == "true"
107
57
  migrations = DataMigrate::DatabaseTasks.past_migrations.keep_if{|m| m[:version] == version}
108
58
 
@@ -122,10 +72,7 @@ namespace :db do
122
72
  namespace :status do
123
73
  desc "Display status of data and schema migrations"
124
74
  task :with_data => :environment do
125
- ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config|
126
- ActiveRecord::Base.establish_connection(db_config)
127
- DataMigrate::Tasks::DataMigrateTasks.status_with_schema(db_config)
128
- end
75
+ DataMigrate::Tasks::DataMigrateTasks.status_with_schema
129
76
  end
130
77
  end
131
78
  end # END OF MIGRATE NAME SPACE
@@ -134,7 +81,7 @@ namespace :db do
134
81
  desc 'Rolls the schema back to the previous version (specify steps w/ STEP=n).'
135
82
  task :with_data => :environment do
136
83
  step = ENV['STEP'] ? ENV['STEP'].to_i : 1
137
- DataMigrate::DataMigrator.assure_data_schema_table
84
+ DataMigrate::DataMigrator.create_data_schema_table
138
85
  DataMigrate::DatabaseTasks.past_migrations[0..(step - 1)].each do | past_migration |
139
86
  DataMigrate::DatabaseTasks.run_migration(past_migration, :down)
140
87
  end
@@ -147,7 +94,7 @@ namespace :db do
147
94
  namespace :forward do
148
95
  desc 'Pushes the schema to the next version (specify steps w/ STEP=n).'
149
96
  task :with_data => :environment do
150
- DataMigrate::DataMigrator.assure_data_schema_table
97
+ DataMigrate::DataMigrator.create_data_schema_table
151
98
  step = ENV['STEP'] ? ENV['STEP'].to_i : 1
152
99
  DataMigrate::DatabaseTasks.forward(step)
153
100
  Rake::Task["db:_dump"].invoke
@@ -158,7 +105,7 @@ namespace :db do
158
105
  namespace :version do
159
106
  desc "Retrieves the current schema version numbers for data and schema migrations"
160
107
  task :with_data => :environment do
161
- DataMigrate::DataMigrator.assure_data_schema_table
108
+ DataMigrate::DataMigrator.create_data_schema_table
162
109
  puts "Current Schema version: #{ActiveRecord::Migrator.current_version}"
163
110
  puts "Current Data version: #{DataMigrate::DataMigrator.current_version}"
164
111
  end
@@ -199,25 +146,26 @@ namespace :db do
199
146
  end
200
147
  end
201
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
202
156
  end
203
157
 
204
158
  namespace :data do
205
159
  desc 'Migrate data migrations (options: VERSION=x, VERBOSE=false)'
206
160
  task :migrate => :environment do
207
- original_db_config = ActiveRecord::Base.connection_db_config
208
- ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config|
209
- ActiveRecord::Base.establish_connection(db_config)
210
- DataMigrate::Tasks::DataMigrateTasks.migrate
211
- end
161
+ DataMigrate::Tasks::DataMigrateTasks.migrate
212
162
  Rake::Task["data:dump"].invoke
213
- ensure
214
- ActiveRecord::Base.establish_connection(original_db_config)
215
163
  end
216
164
 
217
165
  namespace :migrate do
218
166
  desc 'Rollbacks the database one migration and re migrate up (options: STEP=x, VERSION=x).'
219
167
  task :redo => :environment do
220
- DataMigrate::DataMigrator.assure_data_schema_table
168
+ DataMigrate::DataMigrator.create_data_schema_table
221
169
  if ENV["VERSION"]
222
170
  Rake::Task["data:migrate:down"].invoke
223
171
  Rake::Task["data:migrate:up"].invoke
@@ -229,7 +177,7 @@ namespace :data do
229
177
 
230
178
  desc 'Runs the "up" for a given migration VERSION.'
231
179
  task :up => :environment do
232
- DataMigrate::DataMigrator.assure_data_schema_table
180
+ DataMigrate::DataMigrator.create_data_schema_table
233
181
  version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
234
182
  raise "VERSION is required" unless version
235
183
  DataMigrate::DataMigrator.run(:up, DataMigrate::DatabaseTasks.data_migrations_path, version)
@@ -240,23 +188,20 @@ namespace :data do
240
188
  task :down => :environment do
241
189
  version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
242
190
  raise "VERSION is required" unless version
243
- DataMigrate::DataMigrator.assure_data_schema_table
191
+ DataMigrate::DataMigrator.create_data_schema_table
244
192
  DataMigrate::DataMigrator.run(:down, DataMigrate::DatabaseTasks.data_migrations_path, version)
245
193
  Rake::Task["data:dump"].invoke
246
194
  end
247
195
 
248
196
  desc "Display status of data migrations"
249
197
  task :status => :environment do
250
- ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config|
251
- ActiveRecord::Base.establish_connection(db_config)
252
- DataMigrate::Tasks::DataMigrateTasks.status(db_config)
253
- end
198
+ DataMigrate::Tasks::DataMigrateTasks.status
254
199
  end
255
200
  end
256
201
 
257
202
  desc 'Rolls the schema back to the previous version (specify steps w/ STEP=n).'
258
203
  task :rollback => :environment do
259
- DataMigrate::DataMigrator.assure_data_schema_table
204
+ DataMigrate::DataMigrator.create_data_schema_table
260
205
  step = ENV['STEP'] ? ENV['STEP'].to_i : 1
261
206
  DataMigrate::DataMigrator.rollback(DataMigrate::DatabaseTasks.data_migrations_path, step)
262
207
  Rake::Task["data:dump"].invoke
@@ -264,7 +209,7 @@ namespace :data do
264
209
 
265
210
  desc 'Pushes the schema to the next version (specify steps w/ STEP=n).'
266
211
  task :forward => :environment do
267
- DataMigrate::DataMigrator.assure_data_schema_table
212
+ DataMigrate::DataMigrator.create_data_schema_table
268
213
  step = ENV['STEP'] ? ENV['STEP'].to_i : 1
269
214
  # TODO: No worky for .forward
270
215
  # DataMigrate::DataMigrator.forward('db/data/', step)
@@ -277,7 +222,7 @@ namespace :data do
277
222
 
278
223
  desc "Retrieves the current schema version number for data migrations"
279
224
  task :version => :environment do
280
- DataMigrate::DataMigrator.assure_data_schema_table
225
+ DataMigrate::DataMigrator.create_data_schema_table
281
226
  puts "Current data version: #{DataMigrate::DataMigrator.current_version}"
282
227
  end
283
228
 
@@ -289,10 +234,7 @@ namespace :data do
289
234
 
290
235
  desc "Create a db/data_schema.rb file that stores the current data version"
291
236
  task dump: :environment do
292
- ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config|
293
- ActiveRecord::Base.establish_connection(db_config)
294
- DataMigrate::Tasks::DataMigrateTasks.dump(db_config)
295
- end
237
+ DataMigrate::Tasks::DataMigrateTasks.dump
296
238
 
297
239
  # Allow this task to be called as many times as required. An example
298
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.0.rc1
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-04-23 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
@@ -198,19 +198,22 @@ files:
198
198
  - ".rspec"
199
199
  - ".rubocop.yml"
200
200
  - ".ruby-style.yml"
201
- - ".ruby-version"
202
- - ".travis.yml"
203
201
  - Appraisals
204
202
  - Changelog.md
205
203
  - Gemfile
206
- - Gemfile.rails6.1
204
+ - Gemfile.lock
207
205
  - LICENSE
208
206
  - README.md
209
207
  - Rakefile
210
208
  - data_migrate.gemspec
211
- - gemfiles/rails_6.0.gemfile
212
209
  - gemfiles/rails_6.1.gemfile
210
+ - gemfiles/rails_6.1.gemfile.lock
213
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
214
217
  - lib/capistrano/data_migrate.rb
215
218
  - lib/capistrano/data_migrate/migrate.rb
216
219
  - lib/data_migrate.rb
@@ -218,14 +221,16 @@ files:
218
221
  - lib/data_migrate/data_migrator.rb
219
222
  - lib/data_migrate/data_schema.rb
220
223
  - lib/data_migrate/data_schema_migration.rb
224
+ - lib/data_migrate/database_configurations_wrapper.rb
221
225
  - lib/data_migrate/database_tasks.rb
222
- - lib/data_migrate/legacy_migrator.rb
223
226
  - lib/data_migrate/migration_context.rb
227
+ - lib/data_migrate/rails_helper.rb
224
228
  - lib/data_migrate/railtie.rb
225
229
  - lib/data_migrate/schema_dumper.rb
226
230
  - lib/data_migrate/schema_migration.rb
227
231
  - lib/data_migrate/status_service.rb
228
232
  - lib/data_migrate/tasks/data_migrate_tasks.rb
233
+ - lib/data_migrate/test.rb
229
234
  - lib/data_migrate/version.rb
230
235
  - lib/generators/data_migrate.rb
231
236
  - lib/generators/data_migration/data_migration_generator.rb
@@ -237,7 +242,6 @@ files:
237
242
  - spec/data_migrate/data_schema_migration_spec.rb
238
243
  - spec/data_migrate/data_spec.rb
239
244
  - spec/data_migrate/database_tasks_spec.rb
240
- - spec/data_migrate/legacy_migrator_spec.rb
241
245
  - spec/data_migrate/migration.rb
242
246
  - spec/data_migrate/migration_context_spec.rb
243
247
  - spec/data_migrate/schema_dumper_spec.rb
@@ -276,7 +280,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
276
280
  - !ruby/object:Gem::Version
277
281
  version: 1.3.1
278
282
  requirements: []
279
- rubygems_version: 3.3.26
283
+ rubygems_version: 3.4.19
280
284
  signing_key:
281
285
  specification_version: 4
282
286
  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
- - 3.2
6
- script: bundle exec rspec
7
- 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
- - rvm: 3.2
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