mongoid_rails_migrations 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
== INSTALL
|
13
13
|
* gem install mongoid_rails_migrations
|
14
14
|
* In your Gemfile, include:
|
15
|
-
gem "mongoid_rails_migrations", ">=0.0.
|
15
|
+
gem "mongoid_rails_migrations", ">=0.0.2" # or whatever the current version happens to be
|
16
16
|
|
17
17
|
== FEATURES AND HOW TO USE
|
18
18
|
* generator:
|
@@ -23,12 +23,11 @@
|
|
23
23
|
* db:migrate:down
|
24
24
|
* db:migrate:up
|
25
25
|
* db:rollback
|
26
|
-
|
27
|
-
* migrations (untested):
|
28
26
|
* db:migrate:redo
|
29
27
|
* db:migrate:reset
|
30
|
-
* db:reseed (
|
28
|
+
* db:reseed (handled by mongoid)
|
29
|
+
* db:version (added to glean current migration)
|
31
30
|
|
32
31
|
== NOTES
|
33
|
-
* Currently, only timestamp generated migrations have been tested, but you should be able to toggle the value of Mongoid.timestamped_migrations to auto generate
|
32
|
+
* Currently, only timestamp generated migrations have been tested, but you should be able to toggle the value of Mongoid.timestamped_migrations to auto generate migrations by type.
|
34
33
|
* Only tested with ruby 1.9.1
|
@@ -20,6 +20,11 @@ namespace :db do
|
|
20
20
|
task :create => :environment do
|
21
21
|
# noop
|
22
22
|
end
|
23
|
+
|
24
|
+
desc 'Current database version'
|
25
|
+
task :version => :environment do
|
26
|
+
puts Mongoid::Migrator.current_version.to_s
|
27
|
+
end
|
23
28
|
|
24
29
|
desc "Migrate the database through scripts in db/migrate. Target specific version with VERSION=x. Turn off output with VERBOSE=false."
|
25
30
|
task :migrate => :environment do
|
@@ -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.2'
|
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
|
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.author = 'Alan Da Costa'
|
13
13
|
s.email = 'alandacosta@gmail.com.com'
|
14
14
|
s.date = %q{2010-05-12}
|
15
|
-
|
15
|
+
s.homepage = 'http://github.com/adacosta/mongoid_rails_migrations'
|
16
16
|
|
17
17
|
s.require_paths = ["lib"]
|
18
18
|
s.files = Dir['.gitignore', 'Gemfile', 'Rakefile', 'README.rdoc', 'mongoid_rails_migrations.gemspec', 'VERSION', 'lib/**/*']
|
data/test/migration_test.rb
CHANGED
@@ -12,21 +12,26 @@ end
|
|
12
12
|
|
13
13
|
module Mongoid
|
14
14
|
class TestCase < ActiveSupport::TestCase #:nodoc:
|
15
|
-
|
15
|
+
|
16
16
|
def setup
|
17
17
|
Mongoid::Migration.verbose = true
|
18
18
|
end
|
19
19
|
|
20
20
|
def teardown
|
21
21
|
Mongoid.master.collections.each(&:drop)
|
22
|
-
end
|
23
|
-
|
22
|
+
end
|
23
|
+
|
24
24
|
def test_finds_migrations
|
25
25
|
assert Mongoid::Migrator.new(:up, MIGRATIONS_ROOT + "/valid").migrations.size == 2
|
26
|
-
|
26
|
+
|
27
27
|
assert_equal 2, Mongoid::Migrator.new(:up, MIGRATIONS_ROOT + "/valid").pending_migrations.size
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
|
+
def test_migrator_current_version
|
31
|
+
Mongoid::Migrator.migrate(MIGRATIONS_ROOT + "/valid", 20100513054656)
|
32
|
+
assert_equal(20100513054656, Mongoid::Migrator.current_version)
|
33
|
+
end
|
34
|
+
|
30
35
|
def test_migrator
|
31
36
|
assert SurveySchema.first.nil?
|
32
37
|
|
@@ -37,31 +42,31 @@ module Mongoid
|
|
37
42
|
|
38
43
|
Mongoid::Migrator.down(MIGRATIONS_ROOT + "/valid")
|
39
44
|
assert_equal 0, Mongoid::Migrator.current_version
|
40
|
-
|
45
|
+
|
41
46
|
assert SurveySchema.create(:label => 'Questionable Survey')
|
42
47
|
assert_equal 1, SurveySchema.all.size
|
43
48
|
end
|
44
|
-
|
49
|
+
|
45
50
|
def test_migrator_two_up_and_one_down
|
46
51
|
assert SurveySchema.where(:label => 'Baseline Survey').first.nil?
|
47
52
|
assert_equal 0, SurveySchema.all.size
|
48
53
|
|
49
54
|
Mongoid::Migrator.up(MIGRATIONS_ROOT + "/valid", 20100513054656)
|
50
|
-
|
55
|
+
|
51
56
|
assert !SurveySchema.where(:label => 'Baseline Survey').first.nil?
|
52
57
|
assert_equal 1, SurveySchema.all.size
|
53
58
|
|
54
59
|
assert SurveySchema.where(:label => 'Improvement Plan Survey').first.nil?
|
55
|
-
|
60
|
+
|
56
61
|
Mongoid::Migrator.up(MIGRATIONS_ROOT + "/valid", 20100513063902)
|
57
62
|
assert_equal 20100513063902, Mongoid::Migrator.current_version
|
58
|
-
|
63
|
+
|
59
64
|
assert !SurveySchema.where(:label => 'Improvement Plan Survey').first.nil?
|
60
65
|
assert_equal 2, SurveySchema.all.size
|
61
66
|
|
62
67
|
Mongoid::Migrator.down(MIGRATIONS_ROOT + "/valid", 20100513054656)
|
63
68
|
assert_equal 20100513054656, Mongoid::Migrator.current_version
|
64
|
-
|
69
|
+
|
65
70
|
assert SurveySchema.where(:label => 'Improvement Plan Survey').first.nil?
|
66
71
|
assert !SurveySchema.where(:label => 'Baseline Survey').first.nil?
|
67
72
|
assert_equal 1, SurveySchema.all.size
|
@@ -75,7 +80,7 @@ module Mongoid
|
|
75
80
|
assert_equal pending_migrations[0].version, 20100513063902
|
76
81
|
assert_equal pending_migrations[0].name, 'AddImprovementPlanSurveySchema'
|
77
82
|
end
|
78
|
-
|
83
|
+
|
79
84
|
def test_migrator_rollback
|
80
85
|
Mongoid::Migrator.migrate(MIGRATIONS_ROOT + "/valid")
|
81
86
|
assert_equal(20100513063902, Mongoid::Migrator.current_version)
|
@@ -86,7 +91,7 @@ module Mongoid
|
|
86
91
|
Mongoid::Migrator.rollback(MIGRATIONS_ROOT + "/valid")
|
87
92
|
assert_equal(0, Mongoid::Migrator.current_version)
|
88
93
|
end
|
89
|
-
|
94
|
+
|
90
95
|
def test_migrator_forward
|
91
96
|
Mongoid::Migrator.migrate(MIGRATIONS_ROOT + "/valid", 20100513054656)
|
92
97
|
assert_equal(20100513054656, Mongoid::Migrator.current_version)
|
@@ -94,19 +99,19 @@ module Mongoid
|
|
94
99
|
Mongoid::Migrator.forward(MIGRATIONS_ROOT + "/valid", 20100513063902)
|
95
100
|
assert_equal(20100513063902, Mongoid::Migrator.current_version)
|
96
101
|
end
|
97
|
-
|
102
|
+
|
98
103
|
def test_migrator_with_duplicate_names
|
99
104
|
assert_raise(Mongoid::DuplicateMigrationNameError) do
|
100
105
|
Mongoid::Migrator.migrate(MIGRATIONS_ROOT + "/duplicate/names", nil)
|
101
106
|
end
|
102
107
|
end
|
103
|
-
|
108
|
+
|
104
109
|
def test_migrator_with_duplicate_versions
|
105
110
|
assert_raise(Mongoid::DuplicateMigrationVersionError) do
|
106
111
|
Mongoid::Migrator.migrate(MIGRATIONS_ROOT + "/duplicate/versions", nil)
|
107
112
|
end
|
108
113
|
end
|
109
|
-
|
114
|
+
|
110
115
|
def test_migrator_with_missing_version_numbers
|
111
116
|
assert_raise(Mongoid::UnknownMigrationVersionError) do
|
112
117
|
Mongoid::Migrator.migrate(MIGRATIONS_ROOT + "/valid", 500)
|
@@ -114,6 +119,4 @@ module Mongoid
|
|
114
119
|
end
|
115
120
|
|
116
121
|
end
|
117
|
-
end
|
118
|
-
|
119
|
-
# migrations = ActiveRecord::Migrator.new(:up, MIGRATIONS_ROOT + "/interleaved/pass_2").pending_migrations
|
122
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 2
|
9
|
+
version: 0.0.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Alan Da Costa
|
@@ -115,7 +115,7 @@ files:
|
|
115
115
|
- lib/rails/generators/mongoid/migration/templates/migration.rb
|
116
116
|
- lib/rails/generators/mongoid/mongoid_generator.rb
|
117
117
|
has_rdoc: true
|
118
|
-
homepage:
|
118
|
+
homepage: http://github.com/adacosta/mongoid_rails_migrations
|
119
119
|
licenses: []
|
120
120
|
|
121
121
|
post_install_message:
|