data_migrate 9.2.0 → 10.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/build.yml +3 -2
  3. data/.github/workflows/gempush.yml +8 -6
  4. data/.gitignore +2 -3
  5. data/.ruby-version +1 -0
  6. data/.travis.yml +14 -0
  7. data/Appraisals +5 -5
  8. data/Changelog.md +2 -33
  9. data/README.md +5 -7
  10. data/data_migrate.gemspec +1 -1
  11. data/gemfiles/{rails_7.1.gemfile → rails_6.0.gemfile} +1 -1
  12. data/gemfiles/rails_6.1.gemfile +1 -1
  13. data/lib/data_migrate/data_migrator.rb +23 -11
  14. data/lib/data_migrate/data_schema.rb +2 -2
  15. data/lib/data_migrate/data_schema_migration.rb +7 -24
  16. data/lib/data_migrate/database_tasks.rb +5 -28
  17. data/lib/data_migrate/legacy_migrator.rb +22 -0
  18. data/lib/data_migrate/migration_context.rb +8 -11
  19. data/lib/data_migrate/schema_dumper.rb +1 -1
  20. data/lib/data_migrate/schema_migration.rb +4 -5
  21. data/lib/data_migrate/status_service.rb +4 -4
  22. data/lib/data_migrate/tasks/data_migrate_tasks.rb +15 -14
  23. data/lib/data_migrate/version.rb +1 -1
  24. data/lib/data_migrate.rb +1 -1
  25. data/spec/data_migrate/data_migrator_spec.rb +14 -17
  26. data/spec/data_migrate/data_schema_migration_spec.rb +8 -25
  27. data/spec/data_migrate/data_spec.rb +1 -1
  28. data/spec/data_migrate/database_tasks_spec.rb +19 -34
  29. data/spec/data_migrate/legacy_migrator_spec.rb +38 -0
  30. data/spec/data_migrate/migration_context_spec.rb +8 -15
  31. data/spec/data_migrate/schema_dumper_spec.rb +3 -6
  32. data/spec/data_migrate/schema_migration_spec.rb +6 -13
  33. data/spec/data_migrate/status_service_spec.rb +4 -7
  34. data/spec/data_migrate/tasks/data_migrate_tasks_spec.rb +14 -13
  35. data/spec/db/data/20091231235959_some_name.rb +1 -1
  36. data/spec/db/data/20171231235959_super_update.rb +1 -1
  37. data/spec/db/migrate/20131111111111_late_migration.rb +1 -1
  38. data/spec/db/migrate/20202020202011_db_migration.rb +1 -1
  39. data/tasks/databases.rake +38 -17
  40. metadata +14 -15
  41. data/Gemfile.lock +0 -148
  42. data/gemfiles/rails_6.1.gemfile.lock +0 -227
  43. data/gemfiles/rails_7.0.gemfile.lock +0 -229
  44. data/gemfiles/rails_7.1.gemfile.lock +0 -262
  45. data/lib/data_migrate/rails_helper.rb +0 -79
data/lib/data_migrate.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require File.join(File.dirname(__FILE__), "data_migrate", "rails_helper")
4
3
  require File.join(File.dirname(__FILE__), "data_migrate", "data_migrator")
5
4
  require File.join(File.dirname(__FILE__), "data_migrate", "data_schema_migration")
6
5
  require File.join(File.dirname(__FILE__), "data_migrate", "data_schema")
@@ -10,6 +9,7 @@ require File.join(File.dirname(__FILE__), "data_migrate", "status_service")
10
9
  require File.join(File.dirname(__FILE__), "data_migrate", "migration_context")
11
10
  require File.join(File.dirname(__FILE__), "data_migrate", "railtie")
12
11
  require File.join(File.dirname(__FILE__), "data_migrate", "tasks/data_migrate_tasks")
12
+ require File.join(File.dirname(__FILE__), "data_migrate", "legacy_migrator")
13
13
  require File.join(File.dirname(__FILE__), "data_migrate", "config")
14
14
  require File.join(File.dirname(__FILE__), "data_migrate", "schema_migration")
15
15
 
@@ -3,8 +3,7 @@
3
3
  require "spec_helper"
4
4
 
5
5
  describe DataMigrate::DataMigrator do
6
- let(:described_class) { DataMigrate::DataMigrator }
7
-
6
+ let(:subject) { DataMigrate::DataMigrator }
8
7
  let(:db_config) do
9
8
  {
10
9
  adapter: "sqlite3",
@@ -14,8 +13,8 @@ describe DataMigrate::DataMigrator do
14
13
 
15
14
  before do
16
15
  ActiveRecord::Base.establish_connection(db_config)
17
- DataMigrate::RailsHelper.schema_migration.create_table
18
- DataMigrate::RailsHelper.data_schema_migration.create_table
16
+ ::ActiveRecord::SchemaMigration.create_table
17
+ DataMigrate::DataSchemaMigration.create_table
19
18
  end
20
19
 
21
20
  after do
@@ -24,24 +23,22 @@ describe DataMigrate::DataMigrator do
24
23
  end
25
24
 
26
25
  describe ".load_migrated" do
27
- let(:migrator) { DataMigrate::RailsHelper.data_migrator(:up, []) }
28
-
29
26
  it "loads migrated versions" do
30
- DataMigrate::RailsHelper.data_schema_migration.create_version(20090000000000)
31
- DataMigrate::RailsHelper.schema_create_version(20100000000000)
32
- DataMigrate::RailsHelper.data_schema_migration.create_version(20110000000000)
33
- DataMigrate::RailsHelper.schema_create_version(20120000000000)
34
- migrated = migrator.load_migrated
27
+ DataMigrate::DataSchemaMigration.create(version: 20090000000000)
28
+ ::ActiveRecord::SchemaMigration.create(version: 20100000000000)
29
+ DataMigrate::DataSchemaMigration.create(version: 20110000000000)
30
+ ::ActiveRecord::SchemaMigration.create(version: 20120000000000)
31
+ migrated = subject.new(:up, []).load_migrated
35
32
  expect(migrated.count).to eq 2
36
33
  expect(migrated).to include 20090000000000
37
34
  expect(migrated).to include 20110000000000
38
35
  end
39
36
  end
40
37
 
41
- describe :create_data_schema_table do
38
+ describe :assure_data_schema_table do
42
39
  it "creates the data_migrations table" do
43
40
  ActiveRecord::Migration.drop_table("data_migrations") rescue nil
44
- described_class.create_data_schema_table
41
+ subject.assure_data_schema_table
45
42
  expect(
46
43
  ActiveRecord::Base.connection.table_exists?("data_migrations")
47
44
  ).to eq true
@@ -50,7 +47,7 @@ describe DataMigrate::DataMigrator do
50
47
 
51
48
  describe "#migrations_status" do
52
49
  it "returns all migrations statuses" do
53
- status = described_class.migrations_status
50
+ status = subject.migrations_status
54
51
  expect(status.length).to eq 2
55
52
  expect(status.first).to eq ["down", "20091231235959", "Some name"]
56
53
  expect(status.second).to eq ["down", "20171231235959", "Super update"]
@@ -60,19 +57,19 @@ describe DataMigrate::DataMigrator do
60
57
  describe :match do
61
58
  context "when the file does not match" do
62
59
  it "returns nil" do
63
- expect(described_class.match("not_a_data_migration_file")).to be_nil
60
+ expect(subject.match("not_a_data_migration_file")).to be_nil
64
61
  end
65
62
  end
66
63
 
67
64
  context "when the file doesn't end in .rb" do
68
65
  it "returns nil" do
69
- expect(described_class.match("20091231235959_some_name.rb.un~")).to be_nil
66
+ expect(subject.match("20091231235959_some_name.rb.un~")).to be_nil
70
67
  end
71
68
  end
72
69
 
73
70
  context "when the file matches" do
74
71
  it "returns a valid MatchData object" do
75
- match_data = described_class.match("20091231235959_some_name.rb")
72
+ match_data = subject.match("20091231235959_some_name.rb")
76
73
 
77
74
  expect(match_data[0]).to eq "20091231235959_some_name.rb"
78
75
  expect(match_data[1]).to eq "20091231235959"
@@ -1,33 +1,16 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe DataMigrate::DataSchemaMigration do
4
- if DataMigrate::RailsHelper.rails_version_equal_to_or_higher_than_7_1
5
- let(:connection) { double(:connection) }
6
- let(:subject) { DataMigrate::DataSchemaMigration.new(connection) }
7
-
8
- describe :table_name do
9
- it "returns correct table name" do
10
- expect(subject.table_name).to eq("data_migrations")
11
- end
12
- end
13
-
14
- describe :index_name do
15
- it "returns correct primary key name" do
16
- expect(subject.primary_key).to eq("version")
17
- end
18
- end
19
- else
20
- let(:subject) { DataMigrate::DataSchemaMigration }
21
- describe :table_name do
22
- it "returns correct table name" do
23
- expect(subject.table_name).to eq("data_migrations")
24
- end
4
+ let(:subject) { DataMigrate::DataSchemaMigration }
5
+ describe :table_name do
6
+ it "returns correct table name" do
7
+ expect(subject.table_name).to eq("data_migrations")
25
8
  end
9
+ end
26
10
 
27
- describe :index_name do
28
- it "returns correct primary key name" do
29
- expect(subject.primary_key).to eq("version")
30
- end
11
+ describe :index_name do
12
+ it "returns correct primary key name" do
13
+ expect(subject.primary_key).to eq("version")
31
14
  end
32
15
  end
33
16
  end
@@ -55,7 +55,7 @@ describe DataMigrate::Data do
55
55
 
56
56
  sql_select = <<-SQL
57
57
  SELECT version
58
- FROM #{DataMigrate::RailsHelper.data_schema_migration.table_name}
58
+ FROM #{DataMigrate::DataSchemaMigration.table_name}
59
59
  SQL
60
60
 
61
61
  db_list_data = ActiveRecord::Base.connection.
@@ -8,6 +8,12 @@ describe DataMigrate::DatabaseTasks do
8
8
  let(:data_migrations_path) {
9
9
  DataMigrate.config.data_migrations_path
10
10
  }
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
19
  # In a normal Rails installation, db_dir would defer to
@@ -21,10 +27,14 @@ describe DataMigrate::DatabaseTasks do
21
27
  allow(DataMigrate::Tasks::DataMigrateTasks).to receive(:migrations_paths) {
22
28
  data_migrations_path
23
29
  }
24
- ActiveRecord::Base.establish_connection({ adapter: "sqlite3", database: "spec/db/test.db" })
25
- hash_config = ActiveRecord::DatabaseConfigurations::HashConfig.new('test', 'test', { adapter: "sqlite3", database: "spec/db/test.db" })
26
- config_obj = ActiveRecord::DatabaseConfigurations.new([hash_config])
27
- allow(ActiveRecord::Base).to receive(:configurations).and_return(config_obj)
30
+ ActiveRecord::Base.establish_connection(db_config)
31
+ if Gem::Dependency.new("rails", ">= 6.1").match?("rails", Gem.loaded_specs["rails"].version)
32
+ hash_config = ActiveRecord::DatabaseConfigurations::HashConfig.new('test', 'test', db_config)
33
+ config_obj = ActiveRecord::DatabaseConfigurations.new([hash_config])
34
+ allow(ActiveRecord::Base).to receive(:configurations).and_return(config_obj)
35
+ else
36
+ ActiveRecord::Base.configurations[:test] = db_config
37
+ end
28
38
  end
29
39
 
30
40
  context "migrations" do
@@ -34,7 +44,7 @@ describe DataMigrate::DatabaseTasks do
34
44
  end
35
45
 
36
46
  before do
37
- DataMigrate::RailsHelper.schema_migration.create_table
47
+ ActiveRecord::SchemaMigration.create_table
38
48
 
39
49
  allow(DataMigrate::SchemaMigration).to receive(:migrations_paths) {
40
50
  migration_path
@@ -59,47 +69,22 @@ describe DataMigrate::DatabaseTasks do
59
69
  end
60
70
 
61
71
  describe :forward do
72
+
62
73
  it "run forward default amount of times" do
63
74
  subject.forward
64
- versions = DataMigrate::RailsHelper.data_schema_migration.normalized_versions
75
+ versions = DataMigrate::DataSchemaMigration.normalized_versions
65
76
  expect(versions.count).to eq(1)
66
77
  end
67
78
 
68
79
  it "run forward defined number of times" do
69
80
  subject.forward(2)
70
- versions = DataMigrate::RailsHelper.data_schema_migration.normalized_versions
81
+ versions = DataMigrate::DataSchemaMigration.normalized_versions
71
82
  expect(versions.count).to eq(1)
72
83
  expect(versions.first).to eq "20091231235959"
73
- versions = DataMigrate::RailsHelper.schema_migration.normalized_versions
84
+ versions = ActiveRecord::SchemaMigration.normalized_versions
74
85
  expect(versions.count).to eq(1)
75
86
  expect(versions.first).to eq "20131111111111"
76
87
  end
77
88
  end
78
-
79
- if DataMigrate::RailsHelper.rails_version_equal_to_or_higher_than_7_0
80
- describe :schema_dump_path do
81
- before do
82
- allow(ActiveRecord::Base).to receive(:configurations).and_return(ActiveRecord::DatabaseConfigurations.new([db_config]))
83
- end
84
-
85
- context "for primary database" do
86
- let(:db_config) { ActiveRecord::DatabaseConfigurations::HashConfig.new("development", "primary", {} ) }
87
-
88
- context "for :ruby db format" do
89
- it 'returns the data schema path' do
90
- allow(ActiveRecord).to receive(:schema_format).and_return(:ruby)
91
- expect(subject.schema_dump_path(db_config)).to eq("db/data_schema.rb")
92
- end
93
- end
94
-
95
- context "for :sql db format" do
96
- it 'returns the data schema path' do
97
- allow(ActiveRecord).to receive(:schema_format).and_return(:sql)
98
- expect(subject.schema_dump_path(db_config, :sql)).to eq("db/data_schema.rb")
99
- end
100
- end
101
- end
102
- end
103
- end
104
89
  end
105
90
  end
@@ -0,0 +1,38 @@
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
@@ -5,17 +5,10 @@ require "spec_helper"
5
5
  describe DataMigrate::DataMigrator do
6
6
  let(:context) { DataMigrate::MigrationContext.new("spec/db/data") }
7
7
  let(:schema_context) { ActiveRecord::MigrationContext.new("spec/db/migrate", ActiveRecord::Base.connection.schema_migration) }
8
- let(:db_config) do
9
- {
10
- adapter: "sqlite3",
11
- database: "spec/db/test.db"
12
- }
13
- end
14
8
 
15
9
  before do
16
- ActiveRecord::Base.establish_connection(db_config)
17
- DataMigrate::RailsHelper.schema_migration.create_table
18
- DataMigrate::RailsHelper.data_schema_migration.create_table
10
+ ActiveRecord::SchemaMigration.create_table
11
+ DataMigrate::DataSchemaMigration.create_table
19
12
  end
20
13
 
21
14
  after do
@@ -27,7 +20,7 @@ describe DataMigrate::DataMigrator do
27
20
  it "migrates existing file" do
28
21
  context.migrate(nil)
29
22
  context.migrations_status
30
- versions = DataMigrate::RailsHelper.data_schema_migration.normalized_versions
23
+ versions = DataMigrate::DataSchemaMigration.normalized_versions
31
24
  expect(versions.count).to eq(2)
32
25
  expect(versions).to include("20091231235959")
33
26
  expect(versions).to include("20171231235959")
@@ -36,7 +29,7 @@ describe DataMigrate::DataMigrator do
36
29
  it "undo migration" do
37
30
  context.migrate(nil)
38
31
  context.run(:down, 20171231235959)
39
- versions = DataMigrate::RailsHelper.data_schema_migration.normalized_versions
32
+ versions = DataMigrate::DataSchemaMigration.normalized_versions
40
33
  expect(versions.count).to eq(1)
41
34
  expect(versions).to include("20091231235959")
42
35
  end
@@ -53,7 +46,7 @@ describe DataMigrate::DataMigrator do
53
46
 
54
47
  it "runs a specific migration" do
55
48
  context.run(:up, 20171231235959)
56
- versions = DataMigrate::RailsHelper.data_schema_migration.normalized_versions
49
+ versions = DataMigrate::DataSchemaMigration.normalized_versions
57
50
  expect(versions.count).to eq(1)
58
51
  expect(versions).to include("20171231235959")
59
52
  end
@@ -81,7 +74,7 @@ describe DataMigrate::DataMigrator do
81
74
  expect {
82
75
  context.rollback
83
76
  }.to output(/Undoing SuperUpdate/).to_stdout
84
- versions = DataMigrate::RailsHelper.data_schema_migration.normalized_versions
77
+ versions = DataMigrate::DataSchemaMigration.normalized_versions
85
78
  expect(versions.count).to eq(1)
86
79
  expect(versions).to include("20091231235959")
87
80
  end
@@ -92,7 +85,7 @@ describe DataMigrate::DataMigrator do
92
85
  expect {
93
86
  context.rollback(2)
94
87
  }.to output(/Undoing SomeName/).to_stdout
95
- versions = DataMigrate::RailsHelper.data_schema_migration.normalized_versions
88
+ versions = DataMigrate::DataSchemaMigration.normalized_versions
96
89
  expect(versions.count).to eq(0)
97
90
  end
98
91
 
@@ -101,7 +94,7 @@ describe DataMigrate::DataMigrator do
101
94
  expect {
102
95
  context.rollback(2)
103
96
  }.to output(/Undoing SomeName/).to_stdout
104
- versions = DataMigrate::RailsHelper.data_schema_migration.normalized_versions
97
+ versions = DataMigrate::DataSchemaMigration.normalized_versions
105
98
  expect(versions.count).to eq(0)
106
99
  end
107
100
  end
@@ -9,12 +9,9 @@ describe DataMigrate::SchemaDumper do
9
9
  end
10
10
 
11
11
  before do
12
- DataMigrate::RailsHelper.schema_migration.create_table
13
- DataMigrate::RailsHelper.data_schema_migration.create_table
14
-
15
- fixture_file_timestamps.map do |t|
16
- DataMigrate::RailsHelper.data_schema_migration.create_version(t)
17
- end
12
+ ActiveRecord::SchemaMigration.create_table
13
+ DataMigrate::DataSchemaMigration.create_table
14
+ DataMigrate::DataSchemaMigration.create(fixture_file_timestamps.map { |t| { version: t } })
18
15
  end
19
16
 
20
17
  after do
@@ -8,17 +8,10 @@ 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
17
11
 
18
12
  before do
19
- ActiveRecord::Base.establish_connection(db_config)
20
- DataMigrate::RailsHelper.schema_migration.create_table
21
- DataMigrate::RailsHelper.data_schema_migration.create_table
13
+ ActiveRecord::SchemaMigration.create_table
14
+ DataMigrate::DataSchemaMigration.create_table
22
15
  end
23
16
 
24
17
  after do
@@ -45,7 +38,7 @@ describe DataMigrate::SchemaMigration do
45
38
  expect {
46
39
  subject.run(:up, migration_path, 20202020202011)
47
40
  }.to output(/20202020202011 DbMigration: migrating/).to_stdout
48
- versions = DataMigrate::RailsHelper.schema_migration.normalized_versions
41
+ versions = ActiveRecord::SchemaMigration.normalized_versions
49
42
  expect(versions.first).to eq("20202020202011")
50
43
  end
51
44
 
@@ -56,7 +49,7 @@ describe DataMigrate::SchemaMigration do
56
49
  subject.run(:down, migration_path, 20202020202011)
57
50
  }.to output(/Undoing DbMigration/).to_stdout
58
51
 
59
- versions = DataMigrate::RailsHelper.schema_migration.normalized_versions
52
+ versions = ActiveRecord::SchemaMigration.normalized_versions
60
53
 
61
54
  expect(versions.count).to eq(0)
62
55
  end
@@ -68,9 +61,9 @@ describe DataMigrate::SchemaMigration do
68
61
  let(:paths) { ['spec/db/migrate', 'spec/db/migrate/other'] }
69
62
  let(:specification_name) { "primary" }
70
63
  let(:config_options) do
71
- if Gem::Dependency.new("railties", "~> 6.1").match?("railties", Gem.loaded_specs["railties"].version)
64
+ if Gem::Dependency.new("rails", "~> 6.0").match?("rails", Gem.loaded_specs["rails"].version)
72
65
  { env_name: Rails.env, spec_name: specification_name }
73
- else
66
+ elsif Gem::Dependency.new("rails", "~> 7.0").match?("rails", Gem.loaded_specs["rails"].version)
74
67
  { env_name: Rails.env, name: specification_name }
75
68
  end
76
69
  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("railties", ">= 6.1").match?("railties", Gem.loaded_specs["railties"].version)
10
+ if Gem::Dependency.new("rails", ">= 6.1").match?("rails", Gem.loaded_specs["rails"].version)
11
11
  ActiveRecord::Base.connection_db_config
12
12
  else
13
13
  ActiveRecord::Base.configurations.configs_for.first
@@ -33,12 +33,9 @@ describe DataMigrate::StatusService do
33
33
  end
34
34
 
35
35
  before do
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
36
+ ActiveRecord::SchemaMigration.create_table
37
+ DataMigrate::DataSchemaMigration.create_table
38
+ DataMigrate::DataSchemaMigration.create(fixture_file_timestamps.map { |t| { version: t } })
42
39
 
43
40
  subject.dump(connection_db_config, stream)
44
41
  stream.rewind
@@ -3,17 +3,17 @@
3
3
  require "spec_helper"
4
4
 
5
5
  describe DataMigrate::Tasks::DataMigrateTasks do
6
- let(:db_config) do
7
- {
8
- adapter: "sqlite3",
9
- database: "spec/db/test.db"
10
- }
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
11
12
  end
12
13
 
13
14
  before do
14
- ActiveRecord::Base.establish_connection(db_config)
15
- DataMigrate::RailsHelper.schema_migration.create_table
16
- DataMigrate::RailsHelper.data_schema_migration.create_table
15
+ ActiveRecord::SchemaMigration.create_table
16
+ DataMigrate::DataSchemaMigration.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
35
+ DataMigrate::Tasks::DataMigrateTasks.dump(connection_db_config)
36
36
  end
37
37
  end
38
38
 
@@ -56,7 +56,8 @@ 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
- DataMigrate::Tasks::DataMigrateTasks.dump
59
+
60
+ DataMigrate::Tasks::DataMigrateTasks.dump(connection_db_config)
60
61
  end
61
62
  end
62
63
  end
@@ -115,13 +116,13 @@ describe DataMigrate::Tasks::DataMigrateTasks do
115
116
 
116
117
  it "should display data migration status" do
117
118
  expect {
118
- DataMigrate::Tasks::DataMigrateTasks.status
119
+ DataMigrate::Tasks::DataMigrateTasks.status(connection_db_config)
119
120
  }.to output(/up 20091231235959 Some name/).to_stdout
120
121
  end
121
122
 
122
123
  it "should display schema and data migration status" do
123
124
  expect {
124
- DataMigrate::Tasks::DataMigrateTasks.status_with_schema
125
+ DataMigrate::Tasks::DataMigrateTasks.status_with_schema(connection_db_config)
125
126
  }.to output(match(/up data 20091231235959 Some name/)
126
127
  .and match(/down schema 20131111111111 Late migration/)).to_stdout
127
128
  end
@@ -1,4 +1,4 @@
1
- class SomeName < ActiveRecord::Migration[6.1]
1
+ class SomeName < ActiveRecord::Migration[6.0]
2
2
  def up
3
3
  puts "Doing data migration"
4
4
  end
@@ -1,4 +1,4 @@
1
- class SuperUpdate < ActiveRecord::Migration[6.1]
1
+ class SuperUpdate < ActiveRecord::Migration[6.0]
2
2
  def up
3
3
  puts "Doing SuperUpdate"
4
4
  end
@@ -1,4 +1,4 @@
1
- class LateMigration < ActiveRecord::Migration[6.1]
1
+ class LateMigration < ActiveRecord::Migration[6.0]
2
2
  def up
3
3
  puts "Doing schema LateMigration"
4
4
  end
@@ -1,4 +1,4 @@
1
- class DbMigration < ActiveRecord::Migration[6.1]
1
+ class DbMigration < ActiveRecord::Migration[6.0]
2
2
  def up
3
3
  puts "Doing schema migration"
4
4
  end