rails-data-migrations 1.0.6 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 3a6b25e007eef003d75b2953380781470b2a7bd3
4
- data.tar.gz: 153dc99e165bac154d41f9787be7438703d7af42
2
+ SHA256:
3
+ metadata.gz: ecadfdf1ff6e4b9a293770e5f333f7c297cb6821a946a89d698e829a68f5ed5b
4
+ data.tar.gz: 665d7d252f71febca0da708f838808b1e165a8f94b7e8fa4f8bd6dcc891339b5
5
5
  SHA512:
6
- metadata.gz: ccc415203e5b66c467a6d4635905e57d9b673426ba59cfd4dae1545fdf8753e096e77f49693b52fdd7ceb4d0a271871b8fc56d4e740d0f031df945fa73a36cc9
7
- data.tar.gz: f82dd38e3df83a050b3d85e550593371bdce3ee8e46385ede74f7361d5724ba9a7e5f861ba162e86022d6594183dc008da01d4e37ff17fc42a6a3071bf0a7622
6
+ metadata.gz: 1663219b32be0c3803b827d25a2e5ebb8359324ccd78ba65c7b5eea0e8b0119bd95ee854205767b3aa6beb2ab939dc9202f1811c3dce757a94a23043a2c37913
7
+ data.tar.gz: 7fcac514b7b565bfcd936d975877188a7fc8c9a52baa74ec64c56ce918cf5376bb3a4f632c835027c95d3c1cb05514c15311ee8ddd34b858cdf9402421584b84
@@ -3,4 +3,5 @@ language: ruby
3
3
  rvm:
4
4
  - 2.3.4
5
5
  - 2.4.1
6
- script: appraisal install && appraisal rake && rubocop --fail-level R
6
+ - 2.5.0
7
+ script: bundle exec appraisal install && bundle exec appraisal rake && rubocop --fail-level R
data/Appraisals CHANGED
@@ -21,3 +21,7 @@ end
21
21
  appraise 'rails-5.1' do
22
22
  gem 'rails', '~> 5.1.0'
23
23
  end
24
+
25
+ appraise 'rails-5.2' do
26
+ gem 'rails', '~> 5.2.0'
27
+ end
@@ -26,6 +26,10 @@ module RailsDataMigrations
26
26
  end
27
27
  end
28
28
 
29
+ def current_version
30
+ get_all_versions.max || 0
31
+ end
32
+
29
33
  def schema_migrations_table_name
30
34
  LogEntry.table_name
31
35
  end
@@ -33,6 +37,35 @@ module RailsDataMigrations
33
37
  def migrations_path
34
38
  'db/data_migrations'
35
39
  end
40
+
41
+ def rails_5_2?
42
+ Rails::VERSION::MAJOR > 5 || (Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR >= 2)
43
+ end
44
+
45
+ def list_migrations
46
+ if rails_5_2?
47
+ ::ActiveRecord::MigrationContext.new(migrations_path).migrations
48
+ else
49
+ migrations(migrations_path)
50
+ end
51
+ end
52
+
53
+ def list_pending_migrations
54
+ if rails_5_2?
55
+ already_migrated = get_all_versions
56
+ list_migrations.reject { |m| already_migrated.include?(m.version) }
57
+ else
58
+ open(migrations_path).pending_migrations
59
+ end
60
+ end
61
+
62
+ def run_migration(direction, migrations_path, version)
63
+ if rails_5_2?
64
+ new(direction, list_migrations, version).run
65
+ else
66
+ run(direction, migrations_path, version)
67
+ end
68
+ end
36
69
  end
37
70
  end
38
- end
71
+ end
@@ -1,3 +1,3 @@
1
1
  module RailsDataMigrations
2
- VERSION = '1.0.6'.freeze
2
+ VERSION = '1.1.0'.freeze
3
3
  end
@@ -1,13 +1,13 @@
1
1
  require 'rake'
2
2
 
3
3
  namespace :data do
4
- def migrations_path
5
- RailsDataMigrations::Migrator.migrations_path
6
- end
7
-
8
4
  def apply_single_migration(direction, version)
9
5
  raise 'VERSION is required' unless version
10
- RailsDataMigrations::Migrator.run(direction, migrations_path, version.to_i)
6
+ RailsDataMigrations::Migrator.run_migration(
7
+ direction,
8
+ RailsDataMigrations::Migrator.migrations_path,
9
+ version.to_i
10
+ )
11
11
  end
12
12
 
13
13
  task init_migration: :environment do
@@ -16,21 +16,15 @@ namespace :data do
16
16
 
17
17
  desc 'Apply pending data migrations'
18
18
  task migrate: :init_migration do
19
- source_versions = RailsDataMigrations::Migrator.migrations(migrations_path).collect(&:version)
20
- applied_versions = RailsDataMigrations::Migrator.get_all_versions
21
-
22
- (source_versions - applied_versions).sort.each do |version|
23
- apply_single_migration(:up, version)
19
+ RailsDataMigrations::Migrator.list_pending_migrations.sort_by(&:version).each do |m|
20
+ apply_single_migration(:up, m.version)
24
21
  end
25
22
  end
26
23
 
27
24
  desc 'Mark all pending data migrations complete'
28
25
  task reset: :init_migration do
29
- source_versions = RailsDataMigrations::Migrator.migrations(migrations_path).collect(&:version)
30
- applied_versions = RailsDataMigrations::Migrator.get_all_versions
31
-
32
- (source_versions - applied_versions).sort.each do |version|
33
- RailsDataMigrations::LogEntry.create!(version: version.to_s)
26
+ RailsDataMigrations::Migrator.list_pending_migrations.each do |m|
27
+ RailsDataMigrations::LogEntry.create!(version: m.version.to_s)
34
28
  end
35
29
  end
36
30
 
@@ -61,8 +55,7 @@ namespace :data do
61
55
  task pending: :init_migration do
62
56
  puts "#{format('% 16s', 'Migration ID')} Migration Name"
63
57
  puts '--------------------------------------------------'
64
- migrator = RailsDataMigrations::Migrator
65
- migrator.open(migrator.migrations_path).pending_migrations.each do |m|
58
+ RailsDataMigrations::Migrator.list_pending_migrations.each do |m|
66
59
  puts "#{format('% 16i', m.version)} #{m.name.to_s.titleize}"
67
60
  end
68
61
  end
@@ -20,10 +20,10 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_runtime_dependency 'rails', '>= 4.0.0'
22
22
 
23
+ spec.add_development_dependency 'appraisal', '~> 2.1'
23
24
  spec.add_development_dependency 'bundler', '~> 1.13'
24
25
  spec.add_development_dependency 'rake', '~> 10.0'
25
26
  spec.add_development_dependency 'rspec', '3.5.0'
27
+ spec.add_development_dependency 'rubocop', '0.52.1'
26
28
  spec.add_development_dependency 'sqlite3', '~> 1.3'
27
- spec.add_development_dependency 'appraisal', '~> 2.1'
28
- spec.add_development_dependency 'rubocop'
29
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-data-migrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Glukhov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-27 00:00:00.000000000 Z
11
+ date: 2018-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 4.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: appraisal
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.1'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.1'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -67,47 +81,33 @@ dependencies:
67
81
  - !ruby/object:Gem::Version
68
82
  version: 3.5.0
69
83
  - !ruby/object:Gem::Dependency
70
- name: sqlite3
84
+ name: rubocop
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
- - - "~>"
87
+ - - '='
74
88
  - !ruby/object:Gem::Version
75
- version: '1.3'
89
+ version: 0.52.1
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
- - - "~>"
94
+ - - '='
81
95
  - !ruby/object:Gem::Version
82
- version: '1.3'
96
+ version: 0.52.1
83
97
  - !ruby/object:Gem::Dependency
84
- name: appraisal
98
+ name: sqlite3
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
101
  - - "~>"
88
102
  - !ruby/object:Gem::Version
89
- version: '2.1'
103
+ version: '1.3'
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
108
  - - "~>"
95
109
  - !ruby/object:Gem::Version
96
- version: '2.1'
97
- - !ruby/object:Gem::Dependency
98
- name: rubocop
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
110
+ version: '1.3'
111
111
  description:
112
112
  email:
113
113
  - sergey.glukhov@gmail.com
@@ -154,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
154
  version: '0'
155
155
  requirements: []
156
156
  rubyforge_project:
157
- rubygems_version: 2.6.13
157
+ rubygems_version: 2.7.6
158
158
  signing_key:
159
159
  specification_version: 4
160
160
  summary: Run your data migration tasks in a db:migrate-like manner