mongoid_rails_migrations 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
module Mongoid #:nodoc
|
4
|
-
class Config
|
4
|
+
class Config
|
5
5
|
# Specify whether or not to use timestamps for migration versions
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
cattr_accessor :timestamped_migrations
|
7
|
+
@@timestamped_migrations ||= true # default true
|
8
|
+
|
9
|
+
def self.reset
|
10
|
+
@@timestamped_migrations = true
|
10
11
|
end
|
11
12
|
end
|
12
13
|
end
|
@@ -1,8 +1,7 @@
|
|
1
1
|
namespace :db do
|
2
|
-
|
3
2
|
desc 'Drops all the collections for the database for the current Rails.env'
|
4
3
|
task :drop => :environment do
|
5
|
-
Mongoid.master.collections.each{|col| col.
|
4
|
+
Mongoid.master.collections.each {|col| col.drop_indexes && col.drop unless ['system.indexes', 'system.users'].include?(col.name) }
|
6
5
|
end
|
7
6
|
|
8
7
|
desc 'Load the seed data from db/seeds.rb'
|
@@ -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.5'
|
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/helper.rb
CHANGED
@@ -2,4 +2,32 @@ $:.unshift(File.dirname(__FILE__)) unless
|
|
2
2
|
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
3
|
|
4
4
|
require 'config'
|
5
|
-
require 'test/unit'
|
5
|
+
require 'test/unit'
|
6
|
+
|
7
|
+
require 'rake'
|
8
|
+
require 'rake/testtask'
|
9
|
+
require 'rake/rdoctask'
|
10
|
+
|
11
|
+
# leave out active_record, in favor of a monogo adapter
|
12
|
+
%w(
|
13
|
+
action_controller
|
14
|
+
action_mailer
|
15
|
+
active_resource
|
16
|
+
rails/test_unit
|
17
|
+
mongoid
|
18
|
+
).each do |framework|
|
19
|
+
begin
|
20
|
+
require "#{framework}/railtie"
|
21
|
+
rescue LoadError
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
module TestMongoidRailsMigrations
|
26
|
+
class Application < Rails::Application; end
|
27
|
+
end
|
28
|
+
|
29
|
+
# TestMongoidRailsMigrations::Application.initialize!
|
30
|
+
Rails::Application.load_tasks
|
31
|
+
|
32
|
+
# test overrides (dummy path); Rails is really looking for the app environment.rb
|
33
|
+
Rails.configuration.paths.config.environment = 'test/config.rb'
|
data/test/migration_test.rb
CHANGED
@@ -15,10 +15,14 @@ module Mongoid
|
|
15
15
|
|
16
16
|
def setup
|
17
17
|
Mongoid::Migration.verbose = true
|
18
|
+
# same as db:drop command in lib/mongoid_rails_migrations/mongoid_ext/railties/database.rake
|
19
|
+
Mongoid.master.collections.each {|col| col.drop_indexes && col.drop unless ['system.indexes', 'system.users'].include?(col.name) }
|
18
20
|
end
|
19
21
|
|
20
|
-
def teardown
|
21
|
-
|
22
|
+
def teardown; end
|
23
|
+
|
24
|
+
def test_drop_works
|
25
|
+
assert_equal 0, Mongoid::Migrator.current_version, "db:drop should take us down to version 0"
|
22
26
|
end
|
23
27
|
|
24
28
|
def test_finds_migrations
|
@@ -32,7 +36,7 @@ module Mongoid
|
|
32
36
|
end
|
33
37
|
|
34
38
|
def test_migrator
|
35
|
-
assert SurveySchema.first.nil
|
39
|
+
assert SurveySchema.first.nil?, "All SurveySchemas should be clear before migration run"
|
36
40
|
|
37
41
|
Mongoid::Migrator.up(MIGRATIONS_ROOT + "/valid")
|
38
42
|
|
@@ -116,12 +120,21 @@ module Mongoid
|
|
116
120
|
Mongoid::Migrator.migrate(MIGRATIONS_ROOT + "/valid", 500)
|
117
121
|
end
|
118
122
|
end
|
119
|
-
|
123
|
+
|
124
|
+
def test_default_state_of_timestamped_migrations
|
125
|
+
assert Mongoid.config.timestamped_migrations, "Mongoid.config.timestamped_migrations should default to true"
|
126
|
+
end
|
127
|
+
|
128
|
+
def test_timestamped_migrations_generates_non_sequential_next_number
|
129
|
+
next_number = Mongoid::Generators::Base.next_migration_number(MIGRATIONS_ROOT + "/valid")
|
130
|
+
assert_not_equal "20100513063903", next_number
|
131
|
+
end
|
132
|
+
|
120
133
|
def test_turning_off_timestamped_migrations
|
121
134
|
Mongoid.config.timestamped_migrations = false
|
122
135
|
next_number = Mongoid::Generators::Base.next_migration_number(MIGRATIONS_ROOT + "/valid")
|
123
136
|
assert_equal "20100513063903", next_number
|
124
137
|
end
|
125
|
-
|
138
|
+
|
126
139
|
end
|
127
140
|
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: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
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: 1253177454
|
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: -1108848090
|
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: -1108848090
|
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: -1108848090
|
97
97
|
segments:
|
98
98
|
- 3
|
99
99
|
- 0
|