mongoid_rails_migrations 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +3 -1
- data/Gemfile +1 -1
- data/lib/mongoid_rails_migrations/active_record_ext/migrations.rb +1 -1
- data/lib/mongoid_rails_migrations/mongoid_ext/mongoid.rb +6 -2
- data/lib/rails/generators/mongoid/mongoid_generator.rb +2 -1
- data/mongoid_rails_migrations.gemspec +1 -1
- data/test/config.rb +1 -0
- data/test/migration_test.rb +8 -3
- metadata +7 -7
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -55,7 +55,7 @@ module Mongoid #:nodoc
|
|
55
55
|
# If you'd prefer to use numeric prefixes, you can turn timestamped migrations
|
56
56
|
# off by setting:
|
57
57
|
#
|
58
|
-
# config.
|
58
|
+
# Mongoid.config.timestamped_migrations = false
|
59
59
|
#
|
60
60
|
# In environment.rb.
|
61
61
|
#
|
@@ -1,8 +1,12 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
module Mongoid #:nodoc
|
4
|
-
class
|
4
|
+
class Config #:nodoc
|
5
5
|
# Specify whether or not to use timestamps for migration versions
|
6
|
-
|
6
|
+
attr_accessor :timestamped_migrations
|
7
|
+
|
8
|
+
def reset
|
9
|
+
@timestamped_migrations = true
|
10
|
+
end
|
7
11
|
end
|
8
12
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'rails/generators/named_base'
|
1
2
|
require 'rails/generators/migration'
|
2
3
|
|
3
4
|
module Mongoid #:nodoc:
|
@@ -14,7 +15,7 @@ module Mongoid #:nodoc:
|
|
14
15
|
# Implement the required interface for Rails::Generators::Migration.
|
15
16
|
def self.next_migration_number(dirname) #:nodoc:
|
16
17
|
next_migration_number = current_migration_number(dirname) + 1
|
17
|
-
if Mongoid.timestamped_migrations
|
18
|
+
if Mongoid.config.timestamped_migrations
|
18
19
|
[Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
|
19
20
|
else
|
20
21
|
"%.3d" % next_migration_number
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.platform = Gem::Platform::RUBY
|
3
3
|
s.name = 'mongoid_rails_migrations'
|
4
|
-
s.version = '0.0.
|
4
|
+
s.version = '0.0.4'
|
5
5
|
s.summary = 'Data migrations for Mongoid in Active Record style, minus column input.'
|
6
6
|
s.description = 'Sometimes you just need to migrate data.'
|
7
7
|
|
data/test/config.rb
CHANGED
data/test/migration_test.rb
CHANGED
@@ -18,12 +18,11 @@ module Mongoid
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def teardown
|
21
|
-
Mongoid.master.collections.each(&:drop)
|
21
|
+
Mongoid.master.collections.reject { |c| c.name == 'system.indexes' }.each(&:drop)
|
22
22
|
end
|
23
23
|
|
24
24
|
def test_finds_migrations
|
25
25
|
assert Mongoid::Migrator.new(:up, MIGRATIONS_ROOT + "/valid").migrations.size == 2
|
26
|
-
|
27
26
|
assert_equal 2, Mongoid::Migrator.new(:up, MIGRATIONS_ROOT + "/valid").pending_migrations.size
|
28
27
|
end
|
29
28
|
|
@@ -117,6 +116,12 @@ module Mongoid
|
|
117
116
|
Mongoid::Migrator.migrate(MIGRATIONS_ROOT + "/valid", 500)
|
118
117
|
end
|
119
118
|
end
|
120
|
-
|
119
|
+
|
120
|
+
def test_turning_off_timestamped_migrations
|
121
|
+
Mongoid.config.timestamped_migrations = false
|
122
|
+
next_number = Mongoid::Generators::Base.next_migration_number(MIGRATIONS_ROOT + "/valid")
|
123
|
+
assert_equal "20100513063903", next_number
|
124
|
+
end
|
125
|
+
|
121
126
|
end
|
122
127
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid_rails_migrations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alan Da Costa
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
hash:
|
45
|
+
hash: -2012828558
|
46
46
|
segments:
|
47
47
|
- 2
|
48
48
|
- 0
|
@@ -59,7 +59,7 @@ dependencies:
|
|
59
59
|
requirements:
|
60
60
|
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
hash:
|
62
|
+
hash: 275995622
|
63
63
|
segments:
|
64
64
|
- 3
|
65
65
|
- 0
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
requirements:
|
77
77
|
- - ">="
|
78
78
|
- !ruby/object:Gem::Version
|
79
|
-
hash:
|
79
|
+
hash: 275995622
|
80
80
|
segments:
|
81
81
|
- 3
|
82
82
|
- 0
|
@@ -93,7 +93,7 @@ dependencies:
|
|
93
93
|
requirements:
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
hash:
|
96
|
+
hash: 275995622
|
97
97
|
segments:
|
98
98
|
- 3
|
99
99
|
- 0
|