mongoid_rails_migrations 1.1.0 → 1.1.1

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
2
  SHA1:
3
- metadata.gz: cc240d64d9693691c9f524848a1c71be452a0e93
4
- data.tar.gz: e9246baeb9bea0b58213b6d488bf503f31840277
3
+ metadata.gz: c66ba09b162f9b2a9db6aadc8ed14fc0126795c5
4
+ data.tar.gz: b11d88f13706aaa7cbfa3040548eff78277d0c37
5
5
  SHA512:
6
- metadata.gz: 8e74c99e75a4b94ff48aa564b99249c91a7e71c28b1ab8c814a0ee675816ce505d750c1c9f20af18f7e71377902c97a9ab5581eebfaf4528301333e72d694326
7
- data.tar.gz: 9b33ed0e64fa3c6d92d2aee5d287f353d673b28c5057c159fd97ea05892697d2644a058f225e4294cce8d1af483d7c571b390edfccea34760c67cbaa1016c0e4
6
+ metadata.gz: 7bb0036dce3aa488e344cb4d1e12e5db545568fc1e0191609fe7c980a287a3e0653586baeb8e678572d625fcd868e3883e7ce1aeb7abe792ced976e3be3a8cea
7
+ data.tar.gz: 1ee702dd69a9031212409283a5d70b3e1c0caf6d2d685f47cd22074bfbe3b4b77fcd13fa7059db4b2edaf4cd5ce03dfeda3fd10cef3276574ab6cefe5ab1dd22
data/Gemfile CHANGED
@@ -4,5 +4,4 @@ gemspec :name => 'mongoid_rails_migrations'
4
4
  group :test do
5
5
  gem 'minitest'
6
6
  gem 'pry'
7
- gem 'rake'
8
7
  end
data/Gemfile.lock CHANGED
@@ -11,121 +11,123 @@ PATH
11
11
  GEM
12
12
  remote: http://rubygems.org/
13
13
  specs:
14
- actionmailer (4.2.0)
15
- actionpack (= 4.2.0)
16
- actionview (= 4.2.0)
17
- activejob (= 4.2.0)
14
+ actioncable (5.2.0)
15
+ actionpack (= 5.2.0)
16
+ nio4r (~> 2.0)
17
+ websocket-driver (>= 0.6.1)
18
+ actionmailer (5.2.0)
19
+ actionpack (= 5.2.0)
20
+ actionview (= 5.2.0)
21
+ activejob (= 5.2.0)
18
22
  mail (~> 2.5, >= 2.5.4)
19
- rails-dom-testing (~> 1.0, >= 1.0.5)
20
- actionpack (4.2.0)
21
- actionview (= 4.2.0)
22
- activesupport (= 4.2.0)
23
- rack (~> 1.6.0)
24
- rack-test (~> 0.6.2)
25
- rails-dom-testing (~> 1.0, >= 1.0.5)
26
- rails-html-sanitizer (~> 1.0, >= 1.0.1)
27
- actionview (4.2.0)
28
- activesupport (= 4.2.0)
23
+ rails-dom-testing (~> 2.0)
24
+ actionpack (5.2.0)
25
+ actionview (= 5.2.0)
26
+ activesupport (= 5.2.0)
27
+ rack (~> 2.0)
28
+ rack-test (>= 0.6.3)
29
+ rails-dom-testing (~> 2.0)
30
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
31
+ actionview (5.2.0)
32
+ activesupport (= 5.2.0)
29
33
  builder (~> 3.1)
30
- erubis (~> 2.7.0)
31
- rails-dom-testing (~> 1.0, >= 1.0.5)
32
- rails-html-sanitizer (~> 1.0, >= 1.0.1)
33
- activejob (4.2.0)
34
- activesupport (= 4.2.0)
35
- globalid (>= 0.3.0)
36
- activemodel (4.2.0)
37
- activesupport (= 4.2.0)
38
- builder (~> 3.1)
39
- activerecord (4.2.0)
40
- activemodel (= 4.2.0)
41
- activesupport (= 4.2.0)
42
- arel (~> 6.0)
43
- activesupport (4.2.0)
44
- i18n (~> 0.7)
45
- json (~> 1.7, >= 1.7.7)
34
+ erubi (~> 1.4)
35
+ rails-dom-testing (~> 2.0)
36
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
37
+ activejob (5.2.0)
38
+ activesupport (= 5.2.0)
39
+ globalid (>= 0.3.6)
40
+ activemodel (5.2.0)
41
+ activesupport (= 5.2.0)
42
+ activerecord (5.2.0)
43
+ activemodel (= 5.2.0)
44
+ activesupport (= 5.2.0)
45
+ arel (>= 9.0)
46
+ activestorage (5.2.0)
47
+ actionpack (= 5.2.0)
48
+ activerecord (= 5.2.0)
49
+ marcel (~> 0.3.1)
50
+ activesupport (5.2.0)
51
+ concurrent-ruby (~> 1.0, >= 1.0.2)
52
+ i18n (>= 0.7, < 2)
46
53
  minitest (~> 5.1)
47
- thread_safe (~> 0.3, >= 0.3.4)
48
54
  tzinfo (~> 1.1)
49
- arel (6.0.0)
50
- bson (2.3.0)
51
- builder (3.2.2)
52
- coderay (1.1.0)
53
- connection_pool (2.1.0)
54
- erubis (2.7.0)
55
- globalid (0.3.0)
56
- activesupport (>= 4.1.0)
57
- hike (1.2.3)
58
- i18n (0.7.0)
59
- json (1.8.1)
60
- loofah (2.0.1)
55
+ arel (9.0.0)
56
+ bson (4.3.0)
57
+ builder (3.2.3)
58
+ coderay (1.1.2)
59
+ concurrent-ruby (1.0.5)
60
+ crass (1.0.4)
61
+ erubi (1.7.1)
62
+ globalid (0.4.1)
63
+ activesupport (>= 4.2.0)
64
+ i18n (1.0.1)
65
+ concurrent-ruby (~> 1.0)
66
+ loofah (2.2.2)
67
+ crass (~> 1.0.2)
61
68
  nokogiri (>= 1.5.9)
62
- mail (2.6.3)
63
- mime-types (>= 1.16, < 3)
64
- method_source (0.8.2)
65
- mime-types (2.4.3)
66
- mini_portile (0.6.2)
67
- minitest (5.5.0)
68
- mongoid (4.0.0)
69
- activemodel (~> 4.0)
70
- moped (~> 2.0.0)
71
- origin (~> 2.1)
72
- tzinfo (>= 0.3.37)
73
- moped (2.0.2)
74
- bson (~> 2.2)
75
- connection_pool (~> 2.0)
76
- optionable (~> 0.2.0)
77
- multi_json (1.10.1)
78
- nokogiri (1.6.5)
79
- mini_portile (~> 0.6.0)
80
- optionable (0.2.0)
81
- origin (2.1.1)
82
- pry (0.10.1)
69
+ mail (2.7.0)
70
+ mini_mime (>= 0.1.1)
71
+ marcel (0.3.2)
72
+ mimemagic (~> 0.3.2)
73
+ method_source (0.9.0)
74
+ mimemagic (0.3.2)
75
+ mini_mime (1.0.0)
76
+ mini_portile2 (2.3.0)
77
+ minitest (5.11.3)
78
+ mongo (2.6.1)
79
+ bson (>= 4.3.0, < 5.0.0)
80
+ mongoid (7.0.1)
81
+ activemodel (>= 5.1, < 6.0.0)
82
+ mongo (>= 2.5.1, < 3.0.0)
83
+ nio4r (2.3.1)
84
+ nokogiri (1.8.4)
85
+ mini_portile2 (~> 2.3.0)
86
+ pry (0.11.3)
83
87
  coderay (~> 1.1.0)
84
- method_source (~> 0.8.1)
85
- slop (~> 3.4)
86
- rack (1.6.0)
87
- rack-test (0.6.2)
88
- rack (>= 1.0)
89
- rails (4.2.0)
90
- actionmailer (= 4.2.0)
91
- actionpack (= 4.2.0)
92
- actionview (= 4.2.0)
93
- activejob (= 4.2.0)
94
- activemodel (= 4.2.0)
95
- activerecord (= 4.2.0)
96
- activesupport (= 4.2.0)
97
- bundler (>= 1.3.0, < 2.0)
98
- railties (= 4.2.0)
99
- sprockets-rails
100
- rails-deprecated_sanitizer (1.0.3)
101
- activesupport (>= 4.2.0.alpha)
102
- rails-dom-testing (1.0.5)
103
- activesupport (>= 4.2.0.beta, < 5.0)
104
- nokogiri (~> 1.6.0)
105
- rails-deprecated_sanitizer (>= 1.0.1)
106
- rails-html-sanitizer (1.0.1)
107
- loofah (~> 2.0)
108
- railties (4.2.0)
109
- actionpack (= 4.2.0)
110
- activesupport (= 4.2.0)
88
+ method_source (~> 0.9.0)
89
+ rack (2.0.5)
90
+ rack-test (1.1.0)
91
+ rack (>= 1.0, < 3)
92
+ rails (5.2.0)
93
+ actioncable (= 5.2.0)
94
+ actionmailer (= 5.2.0)
95
+ actionpack (= 5.2.0)
96
+ actionview (= 5.2.0)
97
+ activejob (= 5.2.0)
98
+ activemodel (= 5.2.0)
99
+ activerecord (= 5.2.0)
100
+ activestorage (= 5.2.0)
101
+ activesupport (= 5.2.0)
102
+ bundler (>= 1.3.0)
103
+ railties (= 5.2.0)
104
+ sprockets-rails (>= 2.0.0)
105
+ rails-dom-testing (2.0.3)
106
+ activesupport (>= 4.2.0)
107
+ nokogiri (>= 1.6)
108
+ rails-html-sanitizer (1.0.4)
109
+ loofah (~> 2.2, >= 2.2.2)
110
+ railties (5.2.0)
111
+ actionpack (= 5.2.0)
112
+ activesupport (= 5.2.0)
113
+ method_source
111
114
  rake (>= 0.8.7)
112
115
  thor (>= 0.18.1, < 2.0)
113
- rake (10.4.2)
114
- slop (3.6.0)
115
- sprockets (2.12.3)
116
- hike (~> 1.2)
117
- multi_json (~> 1.0)
118
- rack (~> 1.0)
119
- tilt (~> 1.1, != 1.3.0)
120
- sprockets-rails (2.2.2)
121
- actionpack (>= 3.0)
122
- activesupport (>= 3.0)
123
- sprockets (>= 2.8, < 4.0)
124
- thor (0.19.1)
125
- thread_safe (0.3.4)
126
- tilt (1.4.1)
127
- tzinfo (1.2.2)
116
+ rake (12.3.1)
117
+ sprockets (3.7.2)
118
+ concurrent-ruby (~> 1.0)
119
+ rack (> 1, < 3)
120
+ sprockets-rails (3.2.1)
121
+ actionpack (>= 4.0)
122
+ activesupport (>= 4.0)
123
+ sprockets (>= 3.0.0)
124
+ thor (0.20.0)
125
+ thread_safe (0.3.6)
126
+ tzinfo (1.2.5)
128
127
  thread_safe (~> 0.1)
128
+ websocket-driver (0.7.0)
129
+ websocket-extensions (>= 0.1.0)
130
+ websocket-extensions (0.1.3)
129
131
 
130
132
  PLATFORMS
131
133
  ruby
@@ -135,3 +137,6 @@ DEPENDENCIES
135
137
  mongoid_rails_migrations!
136
138
  pry
137
139
  rake
140
+
141
+ BUNDLED WITH
142
+ 1.13.7
data/Rakefile CHANGED
@@ -1,4 +1,5 @@
1
1
  $:.unshift(File.dirname(__FILE__))
2
+ require "bundler/gem_tasks"
2
3
 
3
4
  task :default => ['test:mongoid:migrations']
4
5
 
@@ -1,13 +1,9 @@
1
1
  # encoding: utf-8
2
- require 'bundler/setup'
3
- Bundler.require(:mongoid_rails_migrations)
4
2
 
5
- # Add base to path incase not included as a gem
6
- $:.unshift(File.dirname(__FILE__)) unless
7
- $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+ require 'mongoid'
8
4
 
9
5
  require 'mongoid_rails_migrations/version'
10
6
  require 'mongoid_rails_migrations/models/data_migration'
11
7
  require 'mongoid_rails_migrations/mongoid_ext/mongoid'
12
8
  require 'mongoid_rails_migrations/mongoid_ext/railtie'
13
- require 'mongoid_rails_migrations/active_record_ext/migrations'
9
+ require 'mongoid_rails_migrations/active_record_ext/migrations'
@@ -31,14 +31,14 @@ module Mongoid #:nodoc
31
31
 
32
32
  # Data migrations can manage the modification of data. It's a solution to the common problem of modifying
33
33
  # data between code revisions within a document oriented database.
34
- #
34
+ #
35
35
  # Example of simple migration for a system dependency:
36
- #
36
+ #
37
37
  # class AddBaselineSurveySchema < Mongoid::Migration
38
38
  # def self.up
39
39
  # SurveySchema.create(:label => 'Baseline Survey')
40
40
  # end
41
- #
41
+ #
42
42
  # def self.down
43
43
  # SurveySchema.where(:label => 'Baseline Survey').first.destroy
44
44
  # end
@@ -103,7 +103,8 @@ module Mongoid #:nodoc
103
103
 
104
104
  case sym
105
105
  when :up, :down
106
- singleton_class.send(:alias_method_chain, sym, "benchmarks")
106
+ singleton_class.send(:alias_method, "#{sym}_without_benchmarks".to_sym, sym)
107
+ singleton_class.send(:alias_method, sym, "#{sym}_with_benchmarks".to_sym)
107
108
  end
108
109
  ensure
109
110
  @ignore_new_methods = false
@@ -144,7 +145,11 @@ module Mongoid #:nodoc
144
145
 
145
146
  def connection
146
147
  # ActiveRecord::Base.connection
147
- ::Mongoid.default_session
148
+ if ::Mongoid.respond_to?(:default_client)
149
+ ::Mongoid.default_client
150
+ else
151
+ ::Mongoid.default_session
152
+ end
148
153
  end
149
154
 
150
155
  def method_missing(method, *arguments, &block)
@@ -183,6 +188,8 @@ module Mongoid #:nodoc
183
188
 
184
189
  class Migrator#:nodoc:
185
190
  class << self
191
+ attr_writer :migrations_path
192
+
186
193
  def migrate(migrations_path, target_version = nil)
187
194
  case
188
195
  when target_version.nil? then up(migrations_path, target_version)
@@ -212,7 +219,7 @@ module Mongoid #:nodoc
212
219
  end
213
220
 
214
221
  def migrations_path
215
- 'db/migrate'
222
+ @migrations_path ||= ['db/migrate']
216
223
  end
217
224
 
218
225
  # def schema_migrations_table_name
@@ -223,7 +230,7 @@ module Mongoid #:nodoc
223
230
  def get_all_versions
224
231
  # table = Arel::Table.new(schema_migrations_table_name)
225
232
  # Base.connection.select_values(table.project(table['version']).to_sql).map(&:to_i).sort
226
- DataMigration.all.map {|datamigration| datamigration.version.to_i }.sort
233
+ DataMigration.all.map { |datamigration| datamigration.version.to_i }.sort
227
234
  end
228
235
 
229
236
  def current_version
@@ -326,7 +333,9 @@ module Mongoid #:nodoc
326
333
 
327
334
  def migrations
328
335
  @migrations ||= begin
329
- files = Dir["#{@migrations_path}/[0-9]*_*.rb"]
336
+ files = Array(@migrations_path).inject([]) do |files, path|
337
+ files += Dir["#{path}/[0-9]*_*.rb"]
338
+ end
330
339
 
331
340
  migrations = files.inject([]) do |klasses, file|
332
341
  version, name = file.scan(/([0-9]+)_([_a-z0-9]*).rb/).first
@@ -402,4 +411,4 @@ module Mongoid #:nodoc
402
411
  block.call
403
412
  end
404
413
  end
405
- end
414
+ end
@@ -39,7 +39,7 @@ namespace :db do
39
39
  desc "Migrate the database through scripts in db/migrate. Target specific version with VERSION=x. Turn off output with VERBOSE=false."
40
40
  task :migrate => :environment do
41
41
  Mongoid::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
42
- Mongoid::Migrator.migrate("db/migrate/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
42
+ Mongoid::Migrator.migrate(Mongoid::Migrator.migrations_path, ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
43
43
  end
44
44
 
45
45
  namespace :migrate do
@@ -62,21 +62,21 @@ namespace :db do
62
62
  task :up => :environment do
63
63
  version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
64
64
  raise "VERSION is required" unless version
65
- Mongoid::Migrator.run(:up, "db/migrate/", version)
65
+ Mongoid::Migrator.run(:up, Mongoid::Migrator.migrations_path, version)
66
66
  end
67
67
 
68
68
  desc 'Runs the "down" for a given migration VERSION.'
69
69
  task :down => :environment do
70
70
  version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
71
71
  raise "VERSION is required" unless version
72
- Mongoid::Migrator.run(:down, "db/migrate/", version)
72
+ Mongoid::Migrator.run(:down, Mongoid::Migrator.migrations_path, version)
73
73
  end
74
74
  end
75
75
 
76
76
  desc 'Rolls the database back to the previous migration. Specify the number of steps with STEP=n'
77
77
  task :rollback => :environment do
78
78
  step = ENV['STEP'] ? ENV['STEP'].to_i : 1
79
- Mongoid::Migrator.rollback('db/migrate/', step)
79
+ Mongoid::Migrator.rollback(Mongoid::Migrator.migrations_path, step)
80
80
  end
81
81
 
82
82
  namespace :schema do
@@ -1,3 +1,3 @@
1
1
  module MongoidRailsMigrations #:nodoc:
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.1'
3
3
  end
@@ -16,8 +16,13 @@ module Mongoid
16
16
 
17
17
  def setup
18
18
  Mongoid::Migration.verbose = true
19
+ Mongo::Logger.logger.level = 1
19
20
  # same as db:drop command in lib/mongoid_rails_migrations/mongoid_ext/railties/database.rake
20
- Mongoid.default_session.drop
21
+ if Mongoid.respond_to?(:default_client)
22
+ Mongoid.default_client.database.drop
23
+ else
24
+ Mongoid.default_session.drop
25
+ end
21
26
  end
22
27
 
23
28
  def teardown; end
@@ -26,11 +31,26 @@ module Mongoid
26
31
  assert_equal 0, Mongoid::Migrator.current_version, "db:drop should take us down to version 0"
27
32
  end
28
33
 
34
+ def test_migrations_path
35
+ assert_equal ["db/migrate"], Mongoid::Migrator.migrations_path
36
+
37
+ Mongoid::Migrator.migrations_path += ["engines/my_engine/db/migrate"]
38
+
39
+ assert_equal ["db/migrate", "engines/my_engine/db/migrate"], Mongoid::Migrator.migrations_path
40
+ end
41
+
29
42
  def test_finds_migrations
30
43
  assert Mongoid::Migrator.new(:up, MIGRATIONS_ROOT + "/valid").migrations.size == 2
31
44
  assert_equal 2, Mongoid::Migrator.new(:up, MIGRATIONS_ROOT + "/valid").pending_migrations.size
32
45
  end
33
46
 
47
+ def test_finds_migrations_in_multiple_paths
48
+ migration_paths = [MIGRATIONS_ROOT + "/valid", MIGRATIONS_ROOT + "/other_valid"]
49
+
50
+ assert Mongoid::Migrator.new(:up, migration_paths).migrations.size == 3
51
+ assert_equal 3, Mongoid::Migrator.new(:up, migration_paths).pending_migrations.size
52
+ end
53
+
34
54
  def test_migrator_current_version
35
55
  Mongoid::Migrator.migrate(MIGRATIONS_ROOT + "/valid", 20100513054656)
36
56
  assert_equal(20100513054656, Mongoid::Migrator.current_version)
@@ -137,5 +157,9 @@ module Mongoid
137
157
  assert_equal "20100513063903", next_number
138
158
  end
139
159
 
160
+ def test_migration_returns_connection_without_error
161
+ Mongoid::Migration.connection
162
+ end
163
+
140
164
  end
141
- end
165
+ end
@@ -0,0 +1,9 @@
1
+ class AddOtherPlanSurveySchema < Mongoid::Migration
2
+ def self.up
3
+ SurveySchema.create(:label => 'Other Plan Survey')
4
+ end
5
+
6
+ def self.down
7
+ SurveySchema.where(:label => 'Other Plan Survey').first.destroy
8
+ end
9
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_rails_migrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alan Da Costa
@@ -123,6 +123,7 @@ files:
123
123
  - test/migrations/duplicate/names/20100513073724_add_duplicate_survey_schema.rb
124
124
  - test/migrations/duplicate/versions/20100513073457_add_another_duplicate_survey_schema.rb
125
125
  - test/migrations/duplicate/versions/20100513073457_add_duplicate_survey_schema.rb
126
+ - test/migrations/other_valid/20160509073459_add_other_plan_survey_schema.rb
126
127
  - test/migrations/valid/20100513054656_add_baseline_survey_schema.rb
127
128
  - test/migrations/valid/20100513063902_add_improvement_plan_survey_schema.rb
128
129
  - test/models/survey_schema.rb
@@ -146,18 +147,19 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
147
  version: 1.3.6
147
148
  requirements: []
148
149
  rubyforge_project:
149
- rubygems_version: 2.2.2
150
+ rubygems_version: 2.6.13
150
151
  signing_key:
151
152
  specification_version: 4
152
153
  summary: Data migrations for Mongoid in Active Record style, minus column input.
153
154
  test_files:
154
- - test/config.rb
155
- - test/helper.rb
156
- - test/migration_test.rb
157
- - test/migrations/duplicate/names/20100513073457_add_duplicate_survey_schema.rb
158
155
  - test/migrations/duplicate/names/20100513073724_add_duplicate_survey_schema.rb
159
- - test/migrations/duplicate/versions/20100513073457_add_another_duplicate_survey_schema.rb
156
+ - test/migrations/duplicate/names/20100513073457_add_duplicate_survey_schema.rb
160
157
  - test/migrations/duplicate/versions/20100513073457_add_duplicate_survey_schema.rb
158
+ - test/migrations/duplicate/versions/20100513073457_add_another_duplicate_survey_schema.rb
159
+ - test/migrations/other_valid/20160509073459_add_other_plan_survey_schema.rb
161
160
  - test/migrations/valid/20100513054656_add_baseline_survey_schema.rb
162
161
  - test/migrations/valid/20100513063902_add_improvement_plan_survey_schema.rb
162
+ - test/migration_test.rb
163
+ - test/helper.rb
164
+ - test/config.rb
163
165
  - test/models/survey_schema.rb