data_migrate 5.3.2 → 6.0.0.beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/.rbenv-gemsets +2 -0
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +7 -4
  5. data/Appraisals +7 -9
  6. data/Changelog.md +20 -4
  7. data/Gemfile +2 -0
  8. data/Gemfile.rails5.1 +1 -1
  9. data/README.md +20 -20
  10. data/data_migrate.gemspec +2 -2
  11. data/gemfiles/rails_4.2.gemfile +2 -1
  12. data/gemfiles/rails_5.0.gemfile +1 -1
  13. data/gemfiles/rails_5.1.gemfile +1 -1
  14. data/gemfiles/rails_5.2.gemfile +1 -1
  15. data/gemfiles/rails_6.0.gemfile +7 -0
  16. data/lib/data_migrate.rb +13 -4
  17. data/lib/data_migrate/data_migrator.rb +6 -0
  18. data/lib/data_migrate/data_migrator_five.rb +6 -3
  19. data/lib/data_migrate/schema_migration_five.rb +1 -1
  20. data/lib/data_migrate/tasks/data_migrate_tasks.rb +2 -1
  21. data/lib/data_migrate/version.rb +1 -1
  22. data/spec/data_migrate/config_spec.rb +3 -2
  23. data/spec/data_migrate/data_migrator_spec.rb +21 -0
  24. data/spec/data_migrate/database_tasks_spec.rb +4 -10
  25. data/spec/data_migrate/migration_context_spec.rb +13 -4
  26. data/spec/data_migrate/schema_migration_spec.rb +3 -1
  27. data/spec/data_migrate/status_service_spec.rb +1 -1
  28. data/spec/data_migrate/tasks/data_migrate_tasks_spec.rb +2 -17
  29. data/spec/db/{4.2 → 6.0}/20091231235959_some_name.rb +1 -1
  30. data/spec/db/{4.2 → 6.0}/20171231235959_super_update.rb +1 -1
  31. data/spec/db/data-6.0/20091231235959_some_name.rb +9 -0
  32. data/spec/db/data-6.0/20171231235959_super_update.rb +9 -0
  33. data/spec/db/data-6.0/20181128000207_excluded_file.rb.other_ext +1 -0
  34. data/spec/db/migrate/6.0/20131111111111_late_migration.rb +9 -0
  35. data/spec/db/migrate/6.0/20202020202011_db_migration.rb +9 -0
  36. data/spec/spec_helper.rb +26 -4
  37. metadata +28 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 737ac14150dfe99227e19eff42fbe27ad4ed670abf64352497de7d795bb63ffe
4
- data.tar.gz: 44d29c907e88b2fa0cfb2686b9d5a61ac52be77b2d80d528840f3fa7be150a95
3
+ metadata.gz: 5a89e6b7137b3133eddff4fe3cfee3b7de7fe83cc12f851c54e9107605e42b17
4
+ data.tar.gz: e8901f9ff9545af6749af78c02296b1b9346770a6a9387565224bc45b5ec095d
5
5
  SHA512:
6
- metadata.gz: 01436d19ffc4671f27bdbdade83539d8c4a2e2b9ff3a632740beb8851cdeea43c1d39edc6288be41d6d695f268c70706f09a016412438a92c44cc1e86495f2bd
7
- data.tar.gz: d51939c5695ff458db14bb5df3f9a276e3a8d576fcb3372573fa4babbd2bdef29df63e2e51942c52b663f3c76fdeffb3d92769ae042cf0ecf50777cceade98bd
6
+ metadata.gz: 8a2df7fa486110a957f787d53537f2bd515176cb52ba2d45bcb522b01fa31d85a05ee2c459982ca958cefd8cf00a38771432b654d8706288b936d2f879842e1e
7
+ data.tar.gz: a4554ecba2087dee336a0f3e009643d7400d1dfd5495fa4d9ac42d22ddc06bfbe4e24f84476ef47637fe250519b916595771a9bbe440610585b6399f1f95e14b
@@ -0,0 +1,2 @@
1
+ data-migrate
2
+ -global
@@ -0,0 +1 @@
1
+ 2.6.1
@@ -1,12 +1,15 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.9
4
- - 2.3.7
5
3
  - 2.4.4
6
- - 2.5.1
4
+ - 2.5.5
5
+ - 2.6.2
7
6
  script: bundle exec rspec
8
7
  gemfile:
9
- - gemfiles/rails_4.2.gemfile
10
8
  - gemfiles/rails_5.0.gemfile
11
9
  - gemfiles/rails_5.1.gemfile
12
10
  - gemfiles/rails_5.2.gemfile
11
+ - gemfiles/rails_6.0.gemfile
12
+ matrix:
13
+ exclude:
14
+ - rvm: 2.4.4
15
+ gemfile: gemfiles/rails_6.0.gemfile
data/Appraisals CHANGED
@@ -1,17 +1,15 @@
1
- appraise 'rails-4.2' do
2
- gem 'rails', '4.2.8'
3
- # Nokogiri 1.7+ requires Ruby 2.1+
4
- gem 'nokogiri', '1.6.8.1'
5
- end
6
-
7
1
  appraise 'rails-5.0' do
8
- gem 'rails', '5.0.3'
2
+ gem 'rails', '5.0.7.2'
9
3
  end
10
4
 
11
5
  appraise 'rails-5.1' do
12
- gem 'rails', '5.1'
6
+ gem 'rails', '5.1.7'
13
7
  end
14
8
 
15
9
  appraise 'rails-5.2' do
16
- gem 'rails', '~> 5.2.0'
10
+ gem 'rails', '~> 5.2.3'
11
+ end
12
+
13
+ appraise 'rails-6.0' do
14
+ gem 'rails', '~> 6.0.0.beta3'
17
15
  end
@@ -1,16 +1,28 @@
1
- Changelog
2
- =========
1
+ # Changelog
2
+
3
+ ## 6.0.0
4
+
5
+ Support for Rails 6
6
+ No longer supporting Rails 4.2
7
+
8
+ ## 5.3.3
9
+
10
+ Ruby 2.2 and 2.3 are no longer actively validated with tests since they are both EOL
3
11
 
4
12
  ## 5.3.2
13
+
5
14
  Fix capistrano migration tasks to only skip migrations if there are no changes in the db/data and db/migrate folders
6
15
 
7
16
  ## 5.3.1
17
+
8
18
  Change database task to use data_migrations_path_configuration
9
19
 
10
20
  ## 5.3.0
11
- Add support to configure data migration path
21
+
22
+ Add support to configure data migration path
12
23
 
13
24
  ## 5.1.0
25
+
14
26
  Fixes to `db:schema:load:with_data` + `db:structure:load:with_data` definition, thanks to [craineum](https://github.com/craineum)
15
27
 
16
28
  ## 5.0.0
@@ -37,11 +49,15 @@ Deprecated support for rails 4.0
37
49
  Improvements to timestamped migrations, thanks to [Pierre-Michard](https://github.com/Pierre-Michard)
38
50
 
39
51
  ## 3.4.0
52
+
40
53
  `rake data:migrate:status` to return result in chronological order
54
+
41
55
  ## 3.3.1
56
+
42
57
  Regression fix, thanks to [subakva](https://github.com/subakva)
43
58
 
44
59
  ## 3.3.0
60
+
45
61
  The concept of schema:dump to data migrations, thanks to
46
62
  [tobyndockerill](https://github.com/tobyndockerill)
47
63
 
@@ -50,8 +66,8 @@ The concept of schema:dump to data migrations, thanks to
50
66
  data_migrate table into rails schema dump, thanks to
51
67
  [jturkel](https://github.com/jturkel)
52
68
 
53
-
54
69
  ## 3.2.0
70
+
55
71
  - Add support for Rails 5.1
56
72
  - No longer testing EOL rubies
57
73
 
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in data_migrate.gemspec
4
+ gem 'rails', path: "~/ws/rails"
5
+ gem 'sqlite3', "~> 1.4"
4
6
  gemspec
@@ -2,4 +2,4 @@ source "http://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in data_migrate.gemspec
4
4
  gemspec
5
- gem 'rails', '~> 5.1'
5
+ gem 'rails', '~> 5.1.7'
data/README.md CHANGED
@@ -1,12 +1,10 @@
1
- Data Migrate
2
- ====
1
+ # Data Migrate
3
2
 
4
3
  - [![Version](http://img.shields.io/gem/v/data_migrate.svg?style=flat-square)](https://rubygems.org/gems/data_migrate)
5
4
  - [![License](http://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](http://opensource.org/licenses/MIT)
6
5
  - [![Travis](https://img.shields.io/travis/ilyakatz/data-migrate.svg)](https://travis-ci.org/ilyakatz/data-migrate)
7
6
  - [![Reviewed by Hound](https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg)](https://houndci.com)
8
7
 
9
-
10
8
  Run data migrations alongside schema migrations.
11
9
 
12
10
  Data migrations are stored in `db/data`. They act like schema
@@ -19,13 +17,13 @@ is the place to do it.
19
17
  # Why should I use this?
20
18
 
21
19
  Its seems when a project hits a certain size, I get to manipulate data
22
- outside the application itself. Changing defaults, new validations,
20
+ outside the application itself. Changing defaults, new validations,
23
21
  one-to-one to one-to-many... I found it a pain and dodgy to have to
24
22
  step up migrations one by one, run a ruby script of some sort, then
25
- resume migrations. It tanks a lot of the automation of deploy.
23
+ resume migrations. It tanks a lot of the automation of deploy.
26
24
 
27
25
  If you don't use the one off scripts, you could do it as a regular
28
- migration. It'd be much better to keep concerns separate. The benefit
26
+ migration. It'd be much better to keep concerns separate. The benefit
29
27
  of having them separate has to do with your data model.
30
28
 
31
29
  For instance, lets take an absurd example, to illustrate: You have
@@ -34,28 +32,29 @@ After some use, you decide you are going to be a trend setter,
34
32
  and want only one comment per post, and just the text.
35
33
 
36
34
  Given that you:
35
+
37
36
  - write a migration to add a comment column to `Post`
38
37
  - write a migration to move the contents of the first comments to the `Post`
39
38
  - drop the `column_id` column from `Post`
40
39
  - drop the `Comment` model
41
40
  - fix all your tests
42
41
 
43
- You've just got bit. When you `rake setup:development`, the mess gets
42
+ You've just got bit. When you `rake setup:development`, the mess gets
44
43
  mad at you after it creates your database, and starts cranking through
45
- migrations. It gets to the part where you iterate over the comments
46
- and it blows up. You don't have a `Comment` model anymore for it to
47
- even try and get 'all' from. You think you are smarter, and wrap the
44
+ migrations. It gets to the part where you iterate over the comments
45
+ and it blows up. You don't have a `Comment` model anymore for it to
46
+ even try and get 'all' from. You think you are smarter, and wrap the
48
47
  ActiveRecord call in a conditional based on the environment.
49
48
 
50
49
  That's fine until you get that QA gal, and she wants her own thing.
51
50
  Then the UI people get tired of waiting for the full stack to load on page
52
51
  refreshes, so you have to edit past migrations...
53
52
 
54
- With Data Migrate, you have the control. You can generate your
53
+ With Data Migrate, you have the control. You can generate your
55
54
  migrations as schema or data as you would as your work flow. For
56
55
  setting tasks that don't require any intermediate AR activity, like
57
- dev and test, you stick with `db:migrate`. For production and QA, you
58
- change their scripts to `db:migrate:with_data`. Of course you want to
56
+ dev and test, you stick with `db:migrate`. For production and QA, you
57
+ change their scripts to `db:migrate:with_data`. Of course you want to
59
58
  test your migration, so you have the choice of `db:migrate:with_data` or
60
59
  `data:migrate` to just capture that data change.
61
60
 
@@ -70,7 +69,7 @@ table to track all the goodness.
70
69
 
71
70
  ## Rails Support
72
71
 
73
- Support Rails 4.2 through 5.2
72
+ Support Rails 5.0 through 6.0
74
73
 
75
74
  ### Important notes for older versions
76
75
 
@@ -93,6 +92,7 @@ If you've installed previous to v1.1.0, you'll want to delete the
93
92
  `create_data_migrations_table` migration.
94
93
 
95
94
  ## Installation
95
+
96
96
  Add the gem to your project
97
97
 
98
98
  # Gemfile
@@ -104,7 +104,6 @@ So you know, when you use one of the provide rake tasks, a table
104
104
  called `data_migrations` will be created in your database. This
105
105
  is to mirror the way the standard `db` rake tasks work.
106
106
 
107
-
108
107
  ## Usage
109
108
 
110
109
  ### Generating Migrations
@@ -138,15 +137,15 @@ You can generate a data migration as you would a schema migration:
138
137
 
139
138
  Tasks work as they would with the 'vanilla' db version. The 'with_data' addition to the 'db' tasks will run the task in the context of both the data and schema migrations. That is, rake db:rollback:with_data will check to see if it was a schema or data migration invoked last, and do that. Tasks invoked in that space also have an additional line of output, indicating if the action is performed on data or schema.
140
139
 
141
- With 'up' and 'down', you can specify the option 'BOTH', which defaults to false. Using true, will migrate both the data and schema (in the desired direction) if they both match the version provided. Again, going up, schema is given precedence. Down its data.
140
+ With 'up' and 'down', you can specify the option 'BOTH', which defaults to false. Using true, will migrate both the data and schema (in the desired direction) if they both match the version provided. Again, going up, schema is given precedence. Down its data.
142
141
 
143
142
  `rake db:migrate:status:with_data` provides and additional column to indicate which type of migration.
143
+
144
144
  ### Configuration
145
145
 
146
146
  `data_migrate` respects `ActiveRecord::Base.dump_schema_after_migration`. If it is set to `false`, data schema file will not be generated
147
147
 
148
-
149
- By default, data migrations are added to the `db/data/` path.
148
+ By default, data migrations are added to the `db/data/` path.
150
149
  You can override this setting in `config/initializers/data_migrate.rb`
151
150
 
152
151
  ```ruby
@@ -176,13 +175,14 @@ Run tests for a specific version of Rails
176
175
 
177
176
  ```
178
177
  bundle exec appraisal install
179
- bundle exec appraisal rails-4.2 rspec
180
178
  bundle exec appraisal rails-5.0 rspec
179
+ bundle exec appraisal rails-5.2 rspec
181
180
  ```
182
181
 
183
182
  ## Thanks
183
+
184
184
  [Andrew J Vargo](http://github.com/ajvargo) Andrew was the original creator and maintainer of this project!
185
185
 
186
186
  [Jeremy Durham](http://jeremydurham.com/) for fleshing out the idea with me, and providing guidance.
187
187
 
188
- You! Yes, you. Thanks for checking it out.
188
+ You! Yes, you. Thanks for checking it out.
@@ -15,14 +15,14 @@ Gem::Specification.new do |s|
15
15
 
16
16
  s.rubyforge_project = "data_migrate"
17
17
 
18
- s.add_dependency('rails', '>= 4.2')
18
+ s.add_dependency('rails', '>= 5.0')
19
19
  s.add_development_dependency "appraisal"
20
20
  s.add_development_dependency "rake"
21
21
  s.add_development_dependency "rspec"
22
22
  s.add_development_dependency "rspec-core"
23
23
  s.add_development_dependency "pry"
24
24
  s.add_development_dependency "rb-readline"
25
- s.add_development_dependency "sqlite3"
25
+ s.add_development_dependency "sqlite3", "~> 1.3.6"
26
26
  s.add_development_dependency "timecop"
27
27
  s.add_development_dependency "rubocop"
28
28
  s.add_development_dependency "overcommit"
@@ -2,7 +2,8 @@
2
2
 
3
3
  source "http://rubygems.org"
4
4
 
5
- gem "rails", "4.2.8"
5
+ gem "rails", "4.2.11.1"
6
6
  gem "nokogiri", "1.6.8.1"
7
+ gem "bundler" , "< 2.0"
7
8
 
8
9
  gemspec path: "../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "http://rubygems.org"
4
4
 
5
- gem "rails", "5.0.3"
5
+ gem "rails", "5.0.7.2"
6
6
 
7
7
  gemspec path: "../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "http://rubygems.org"
4
4
 
5
- gem "rails", "5.1"
5
+ gem "rails", "5.1.7"
6
6
 
7
7
  gemspec path: "../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "http://rubygems.org"
4
4
 
5
- gem "rails", "~> 5.2.0"
5
+ gem "rails", "~> 5.2.3"
6
6
 
7
7
  gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "rails", "~> 6.0.0.beta3"
6
+
7
+ gemspec path: "../"
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR == 2
3
+ if Rails::VERSION::MAJOR == 6
4
+ require File.join(File.dirname(__FILE__), "data_migrate", "data_migrator_five")
5
+ elsif Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR == 2
4
6
  require File.join(File.dirname(__FILE__), "data_migrate", "data_migrator_five")
5
7
  else
6
8
  require File.join(File.dirname(__FILE__), "data_migrate", "data_migrator")
@@ -10,15 +12,22 @@ require File.join(File.dirname(__FILE__), "data_migrate",
10
12
  require File.join(File.dirname(__FILE__), "data_migrate", "data_schema")
11
13
  require File.join(File.dirname(__FILE__), "data_migrate", "database_tasks")
12
14
  require File.join(File.dirname(__FILE__), "data_migrate", "schema_dumper")
13
- if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR == 2
15
+ if Rails::VERSION::MAJOR == 6
16
+ require File.join(File.dirname(__FILE__), "data_migrate", "status_service_five")
17
+ require File.join(File.dirname(__FILE__), "data_migrate", "schema_migration_five")
18
+ elsif Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR == 2
14
19
  require File.join(File.dirname(__FILE__), "data_migrate", "status_service_five")
15
20
  require File.join(File.dirname(__FILE__), "data_migrate", "schema_migration_five")
16
21
  else
17
22
  require File.join(File.dirname(__FILE__), "data_migrate", "status_service")
18
23
  require File.join(File.dirname(__FILE__), "data_migrate", "schema_migration")
19
24
  end
20
- if Rails::VERSION::MAJOR == 5
21
- if Rails::VERSION::MINOR == 2
25
+
26
+ if Rails::VERSION::MAJOR == 6
27
+ require File.join(File.dirname(__FILE__), "data_migrate", "migration_context")
28
+ # require File.join(File.dirname(__FILE__), "data_migrate", "migration_five")
29
+ elsif Rails::VERSION::MAJOR == 5
30
+ if Rails::VERSION::MINOR == 2
22
31
  require File.join(File.dirname(__FILE__), "data_migrate", "migration_context")
23
32
  else
24
33
  require File.join(File.dirname(__FILE__), "data_migrate", "migration_five")
@@ -20,6 +20,12 @@ module DataMigrate
20
20
  end
21
21
 
22
22
  class << self
23
+ alias_method :migrations_status_orig, :migrations_status
24
+
25
+ def migrations_status
26
+ migrations_status_orig([DataMigrate.config.data_migrations_path])
27
+ end
28
+
23
29
  def current_version(connection = ActiveRecord::Base.connection)
24
30
  get_all_versions(connection).max || 0
25
31
  end
@@ -5,7 +5,9 @@ require "data_migrate/config"
5
5
 
6
6
  module DataMigrate
7
7
  class DataMigrator < ActiveRecord::Migrator
8
- self.migrations_paths = [DataMigrate.config.data_migrations_path]
8
+ def self.migrations_paths
9
+ [DataMigrate.config.data_migrations_path]
10
+ end
9
11
 
10
12
  def self.assure_data_schema_table
11
13
  ActiveRecord::Base.establish_connection(db_config)
@@ -54,9 +56,10 @@ module DataMigrate
54
56
  DataMigrate::MigrationContext.new(migrations_paths).migrations_status
55
57
  end
56
58
 
57
- #TODO: this was added to be backward compatible, need to re-evaluate
59
+ # TODO: this was added to be backward compatible, need to re-evaluate
58
60
  def migrations(_migrations_paths)
59
- DataMigrate::MigrationContext.new(migrations_paths).migrations
61
+ #DataMigrate::MigrationContext.new(migrations_paths).migrations
62
+ DataMigrate::MigrationContext.new(_migrations_paths).migrations
60
63
  end
61
64
 
62
65
  #TODO: this was added to be backward compatible, need to re-evaluate
@@ -3,7 +3,7 @@ module DataMigrate
3
3
  # to allow data/schema combiation tasks
4
4
  class SchemaMigration
5
5
  def self.pending_schema_migrations
6
- all_migrations = ActiveRecord::MigrationContext.new(migrations_paths).migrations
6
+ all_migrations = DataMigrate::MigrationContext.new(migrations_paths).migrations
7
7
  sort_migrations(
8
8
  ActiveRecord::Migrator.new(:up, all_migrations).
9
9
  pending_migrations.
@@ -9,7 +9,8 @@ module DataMigrate
9
9
  def migrate
10
10
  DataMigrate::DataMigrator.assure_data_schema_table
11
11
  target_version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
12
- if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR == 2
12
+ if (Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR == 2) ||
13
+ Rails::VERSION::MAJOR == 6
13
14
  DataMigrate::MigrationContext.new(migrations_paths).migrate(target_version)
14
15
  else
15
16
  DataMigrate::DataMigrator.migrate(migrations_paths, ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
@@ -1,3 +1,3 @@
1
1
  module DataMigrate
2
- VERSION = "5.3.2".freeze
2
+ VERSION = "6.0.0.beta".freeze
3
3
  end
@@ -2,12 +2,13 @@ require "spec_helper"
2
2
 
3
3
  describe DataMigrate::Config do
4
4
 
5
- it "sets default data_migrations_path path" do
5
+ it "sets default data_migrations_path path", :no_override do
6
6
  expect(DataMigrate.config.data_migrations_path).to eq "db/data/"
7
7
  end
8
8
 
9
9
  describe "data migration path configured" do
10
10
  before do
11
+ @before = DataMigrate.config.data_migrations_path
11
12
  DataMigrate.configure do |config|
12
13
  config.data_migrations_path = "db/awesome/"
13
14
  end
@@ -15,7 +16,7 @@ describe DataMigrate::Config do
15
16
 
16
17
  after do
17
18
  DataMigrate.configure do |config|
18
- config.data_migrations_path = "db/data/"
19
+ config.data_migrations_path = @before
19
20
  end
20
21
  end
21
22
 
@@ -9,6 +9,11 @@ describe DataMigrate::DataMigrator do
9
9
  }
10
10
  end
11
11
 
12
+ before do
13
+ allow(DataMigrate::DataMigrator).to receive(:db_config) { db_config }
14
+ ActiveRecord::Base.establish_connection(db_config)
15
+ end
16
+
12
17
  describe :load_migrated do
13
18
  before do
14
19
  allow(subject).to receive(:db_config) { db_config }.at_least(:once)
@@ -56,6 +61,22 @@ describe DataMigrate::DataMigrator do
56
61
  end
57
62
  end
58
63
 
64
+ describe "#migrations_status" do
65
+ before do
66
+ allow(subject).to receive(:db_config) { db_config }.at_least(:once)
67
+ ActiveRecord::Base.establish_connection(db_config)
68
+ ::ActiveRecord::SchemaMigration.create_table
69
+ DataMigrate::DataSchemaMigration.create_table
70
+ end
71
+
72
+ it "returns all migrations statuses" do
73
+ status = subject.migrations_status
74
+ expect(status.length).to eq 2
75
+ expect(status.first).to eq ["down", "20091231235959", "Some name"]
76
+ expect(status.second).to eq ["down", "20171231235959", "Super update"]
77
+ end
78
+ end
79
+
59
80
  describe :match do
60
81
  context "when the file does not match" do
61
82
  it "returns nil" do
@@ -5,7 +5,9 @@ require "spec_helper"
5
5
  describe DataMigrate::DatabaseTasks do
6
6
  let(:subject) { DataMigrate::DatabaseTasks }
7
7
  let(:migration_path) {
8
- if Rails::VERSION::MAJOR == 5
8
+ if Rails::VERSION::MAJOR == 6
9
+ "spec/db/migrate/6.0"
10
+ elsif Rails::VERSION::MAJOR == 5
9
11
  if Rails::VERSION::MINOR == 2
10
12
  "spec/db/migrate/5.2"
11
13
  else
@@ -16,15 +18,7 @@ describe DataMigrate::DatabaseTasks do
16
18
  end
17
19
  }
18
20
  let(:data_migrations_path) {
19
- if Rails::VERSION::MAJOR == 5
20
- if Rails::VERSION::MINOR == 2
21
- "spec/db/data"
22
- else
23
- "spec/db/5.0"
24
- end
25
- else
26
- "spec/db/4.2"
27
- end
21
+ DataMigrate.config.data_migrations_path
28
22
  }
29
23
  let(:db_config) do
30
24
  {
@@ -2,15 +2,24 @@ require "spec_helper"
2
2
 
3
3
  describe DataMigrate::DataMigrator do
4
4
  let(:context) {
5
- DataMigrate::MigrationContext.new("spec/db/data")
5
+ if (Rails::VERSION::MAJOR == 6)
6
+ DataMigrate::MigrationContext.new("spec/db/data-6.0")
7
+ else
8
+ DataMigrate::MigrationContext.new("spec/db/data")
9
+ end
6
10
  }
7
11
  let(:schema_context) {
8
- ActiveRecord::MigrationContext.new("spec/db/migrate/5.2")
12
+ if (Rails::VERSION::MAJOR == 6)
13
+ ActiveRecord::MigrationContext.new("spec/db/migrate/6.0")
14
+ else
15
+ ActiveRecord::MigrationContext.new("spec/db/migrate/5.2")
16
+ end
9
17
  }
10
18
 
11
19
  before do
12
- unless Rails::VERSION::MAJOR == 5 and
13
- Rails::VERSION::MINOR == 2
20
+ unless (Rails::VERSION::MAJOR == 5 and
21
+ Rails::VERSION::MINOR == 2) ||
22
+ Rails::VERSION::MAJOR == 6
14
23
  skip("Tests are only applicable for Rails 5.2")
15
24
  end
16
25
  end
@@ -4,7 +4,9 @@ require "spec_helper"
4
4
 
5
5
  describe DataMigrate::SchemaMigration do
6
6
  let(:migration_path) {
7
- if Rails::VERSION::MAJOR == 5
7
+ if Rails::VERSION::MAJOR == 6
8
+ "spec/db/migrate/6.0"
9
+ elsif Rails::VERSION::MAJOR == 5
8
10
  if Rails::VERSION::MINOR == 2
9
11
  "spec/db/migrate/5.2"
10
12
  else
@@ -46,7 +46,7 @@ describe DataMigrate::StatusService do
46
46
  VALUES #{fixture_file_timestamps.map { |t| "(#{t})" }.join(', ')}
47
47
  SQL
48
48
 
49
- allow_any_instance_of(service).to receive(:root_folder) { "spec" }
49
+ allow_any_instance_of(service).to receive(:root_folder) { "./" }
50
50
  end
51
51
 
52
52
  after do
@@ -11,21 +11,6 @@ describe DataMigrate::Tasks::DataMigrateTasks do
11
11
  end
12
12
 
13
13
  before do
14
- if Rails::VERSION::MAJOR == 5
15
- if Rails::VERSION::MINOR == 2
16
- allow(DataMigrate::Tasks::DataMigrateTasks).to receive(:migrations_paths) {
17
- "spec/db/data"
18
- }
19
- else
20
- allow(DataMigrate::Tasks::DataMigrateTasks).to receive(:migrations_paths) {
21
- "spec/db/5.0"
22
- }
23
- end
24
- else
25
- allow(DataMigrate::Tasks::DataMigrateTasks).to receive(:migrations_paths) {
26
- "spec/db/4.2"
27
- }
28
- end
29
14
  allow(DataMigrate::DataMigrator).to receive(:db_config) { db_config }
30
15
  ActiveRecord::Base.establish_connection(db_config)
31
16
  end
@@ -36,9 +21,9 @@ describe DataMigrate::Tasks::DataMigrateTasks do
36
21
 
37
22
  describe :migrate do
38
23
  it do
39
- expect {
24
+ expect {
40
25
  DataMigrate::Tasks::DataMigrateTasks.migrate
41
- }.to output(/20091231235959 SomeName: migrating/).to_stdout
26
+ }.to output(/20091231235959 SomeName: migrating/).to_stdout
42
27
  end
43
28
 
44
29
  it do
@@ -1,4 +1,4 @@
1
- class SomeName < ActiveRecord::Migration
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
1
+ class SuperUpdate < ActiveRecord::Migration[6.0]
2
2
  def up
3
3
  puts "Doing data migration"
4
4
  end
@@ -0,0 +1,9 @@
1
+ class SomeName < ActiveRecord::Migration[6.0]
2
+ def up
3
+ puts "Doing data migration"
4
+ end
5
+
6
+ def down
7
+ puts "Undoing SomeName"
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class SuperUpdate < ActiveRecord::Migration[6.0]
2
+ def up
3
+ puts "Doing SuperUpdate"
4
+ end
5
+
6
+ def down
7
+ puts "Undoing SuperUpdate"
8
+ end
9
+ end
@@ -0,0 +1 @@
1
+ # This file should be excluded
@@ -0,0 +1,9 @@
1
+ class LateMigration < ActiveRecord::Migration[6.0]
2
+ def up
3
+ puts "Doing schema LateMigration"
4
+ end
5
+
6
+ def down
7
+ puts "Undoing LateMigration"
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class DbMigration < ActiveRecord::Migration[6.0]
2
+ def up
3
+ puts "Doing schema migration"
4
+ end
5
+
6
+ def down
7
+ puts "Undoing DbMigration"
8
+ end
9
+ end
@@ -1,15 +1,37 @@
1
1
  require 'rspec'
2
2
  require 'rails'
3
+ require 'sqlite3'
3
4
  require 'data_migrate'
4
5
  require 'pry'
5
6
  require 'timecop'
6
7
 
7
- if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR == 2
8
- DataMigrate::DataMigrator.migrations_paths = ["spec/db/data"]
9
- end
10
-
11
8
  RSpec.configure do |config|
12
9
  config.mock_with :rspec do |mocks|
13
10
  mocks.verify_partial_doubles = true
14
11
  end
12
+
13
+ config.before(:each) do |example|
14
+ if example.metadata[:no_override]
15
+ else
16
+ if Rails::VERSION::MAJOR == 6
17
+ DataMigrate.configure do |config|
18
+ config.data_migrations_path = "spec/db/6.0"
19
+ end
20
+ elsif Rails::VERSION::MAJOR == 5
21
+ if Rails::VERSION::MINOR == 2
22
+ DataMigrate.configure do |config|
23
+ config.data_migrations_path = "spec/db/data"
24
+ end
25
+ else
26
+ DataMigrate.configure do |config|
27
+ config.data_migrations_path = "spec/db/5.0"
28
+ end
29
+ end
30
+ else
31
+ DataMigrate.configure do |config|
32
+ config.data_migrations_path = "spec/db/5.0"
33
+ end
34
+ end
35
+ end
36
+ end
15
37
  end
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: 5.3.2
4
+ version: 6.0.0.beta
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: 2019-04-01 00:00:00.000000000 Z
13
+ date: 2019-04-26 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -18,14 +18,14 @@ dependencies:
18
18
  requirements:
19
19
  - - ">="
20
20
  - !ruby/object:Gem::Version
21
- version: '4.2'
21
+ version: '5.0'
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: '4.2'
28
+ version: '5.0'
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: appraisal
31
31
  requirement: !ruby/object:Gem::Requirement
@@ -114,16 +114,16 @@ dependencies:
114
114
  name: sqlite3
115
115
  requirement: !ruby/object:Gem::Requirement
116
116
  requirements:
117
- - - ">="
117
+ - - "~>"
118
118
  - !ruby/object:Gem::Version
119
- version: '0'
119
+ version: 1.3.6
120
120
  type: :development
121
121
  prerelease: false
122
122
  version_requirements: !ruby/object:Gem::Requirement
123
123
  requirements:
124
- - - ">="
124
+ - - "~>"
125
125
  - !ruby/object:Gem::Version
126
- version: '0'
126
+ version: 1.3.6
127
127
  - !ruby/object:Gem::Dependency
128
128
  name: timecop
129
129
  requirement: !ruby/object:Gem::Requirement
@@ -178,9 +178,11 @@ files:
178
178
  - ".gitignore"
179
179
  - ".hound.yml"
180
180
  - ".overcommit.yml"
181
+ - ".rbenv-gemsets"
181
182
  - ".rspec"
182
183
  - ".rubocop.yml"
183
184
  - ".ruby-style.yml"
185
+ - ".ruby-version"
184
186
  - ".travis.yml"
185
187
  - Appraisals
186
188
  - Changelog.md
@@ -197,6 +199,7 @@ files:
197
199
  - gemfiles/rails_5.0.gemfile
198
200
  - gemfiles/rails_5.1.gemfile
199
201
  - gemfiles/rails_5.2.gemfile
202
+ - gemfiles/rails_6.0.gemfile
200
203
  - lib/capistrano/data_migrate.rb
201
204
  - lib/capistrano/data_migrate/migrate.rb
202
205
  - lib/data_migrate.rb
@@ -235,10 +238,13 @@ files:
235
238
  - spec/data_migrate/schema_migration_spec.rb
236
239
  - spec/data_migrate/status_service_spec.rb
237
240
  - spec/data_migrate/tasks/data_migrate_tasks_spec.rb
238
- - spec/db/4.2/20091231235959_some_name.rb
239
- - spec/db/4.2/20171231235959_super_update.rb
240
241
  - spec/db/5.0/20091231235959_some_name.rb
241
242
  - spec/db/5.0/20171231235959_super_update.rb
243
+ - spec/db/6.0/20091231235959_some_name.rb
244
+ - spec/db/6.0/20171231235959_super_update.rb
245
+ - spec/db/data-6.0/20091231235959_some_name.rb
246
+ - spec/db/data-6.0/20171231235959_super_update.rb
247
+ - spec/db/data-6.0/20181128000207_excluded_file.rb.other_ext
242
248
  - spec/db/data/20091231235959_some_name.rb
243
249
  - spec/db/data/20171231235959_super_update.rb
244
250
  - spec/db/data/20181128000207_excluded_file.rb.other_ext
@@ -248,6 +254,8 @@ files:
248
254
  - spec/db/migrate/5.0/20202020202011_db_migration.rb
249
255
  - spec/db/migrate/5.2/20131111111111_late_migration.rb
250
256
  - spec/db/migrate/5.2/20202020202011_db_migration.rb
257
+ - spec/db/migrate/6.0/20131111111111_late_migration.rb
258
+ - spec/db/migrate/6.0/20202020202011_db_migration.rb
251
259
  - spec/generators/data_migration/data_migration_generator_spec.rb
252
260
  - spec/spec_helper.rb
253
261
  - tasks/.gitkeep
@@ -273,12 +281,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
273
281
  version: '0'
274
282
  required_rubygems_version: !ruby/object:Gem::Requirement
275
283
  requirements:
276
- - - ">="
284
+ - - ">"
277
285
  - !ruby/object:Gem::Version
278
- version: '0'
286
+ version: 1.3.1
279
287
  requirements: []
280
- rubyforge_project: data_migrate
281
- rubygems_version: 2.7.8
288
+ rubygems_version: 3.0.1
282
289
  signing_key:
283
290
  specification_version: 4
284
291
  summary: Rake tasks to migrate data alongside schema changes.
@@ -295,10 +302,13 @@ test_files:
295
302
  - spec/data_migrate/schema_migration_spec.rb
296
303
  - spec/data_migrate/status_service_spec.rb
297
304
  - spec/data_migrate/tasks/data_migrate_tasks_spec.rb
298
- - spec/db/4.2/20091231235959_some_name.rb
299
- - spec/db/4.2/20171231235959_super_update.rb
300
305
  - spec/db/5.0/20091231235959_some_name.rb
301
306
  - spec/db/5.0/20171231235959_super_update.rb
307
+ - spec/db/6.0/20091231235959_some_name.rb
308
+ - spec/db/6.0/20171231235959_super_update.rb
309
+ - spec/db/data-6.0/20091231235959_some_name.rb
310
+ - spec/db/data-6.0/20171231235959_super_update.rb
311
+ - spec/db/data-6.0/20181128000207_excluded_file.rb.other_ext
302
312
  - spec/db/data/20091231235959_some_name.rb
303
313
  - spec/db/data/20171231235959_super_update.rb
304
314
  - spec/db/data/20181128000207_excluded_file.rb.other_ext
@@ -308,5 +318,7 @@ test_files:
308
318
  - spec/db/migrate/5.0/20202020202011_db_migration.rb
309
319
  - spec/db/migrate/5.2/20131111111111_late_migration.rb
310
320
  - spec/db/migrate/5.2/20202020202011_db_migration.rb
321
+ - spec/db/migrate/6.0/20131111111111_late_migration.rb
322
+ - spec/db/migrate/6.0/20202020202011_db_migration.rb
311
323
  - spec/generators/data_migration/data_migration_generator_spec.rb
312
324
  - spec/spec_helper.rb