exodus 1.1.2 → 1.1.3
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/.rvmrc +1 -1
- data/.travis.yml +1 -1
- data/CHANGELOG.md +5 -1
- data/Gemfile +4 -0
- data/README.md +11 -0
- data/lib/exodus/config/migration_info.rb +1 -1
- data/lib/exodus/migrations/migration.rb +1 -1
- data/lib/exodus/migrations/migration_status.rb +1 -1
- data/lib/exodus/version.rb +1 -1
- data/spec/exodus/migration_spec.rb +37 -0
- data/spec/exodus/migration_status_spec.rb +36 -0
- data/tasks/exodus.rake +1 -1
- metadata +4 -2
data/.rvmrc
CHANGED
@@ -1 +1 @@
|
|
1
|
-
rvm use ruby-1.9.3-p194@exodus
|
1
|
+
rvm use ruby-1.9.3-p194@exodus --create
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## v1.1.3
|
2
|
+
|
3
|
+
* Small changes around rerunnable migrations
|
4
|
+
|
1
5
|
## v1.1.2
|
2
6
|
|
3
7
|
* Exodus now supports custom namespacing to not conflict with AR db:migrate
|
@@ -24,7 +28,7 @@
|
|
24
28
|
|
25
29
|
## v1.0.4
|
26
30
|
|
27
|
-
* Custom migrations now
|
31
|
+
* Custom migrations now run in the given order
|
28
32
|
|
29
33
|
## v1.0.3
|
30
34
|
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -171,4 +171,15 @@ Exodus - A migration framework for MongoDb
|
|
171
171
|
|
172
172
|
rake db:mongo_info
|
173
173
|
|
174
|
+
## Namespacing
|
174
175
|
|
176
|
+
You might be using other gems in your project that uses `rake db:migrate` or `rake db:rollback`. In order to avoid conflicts you can define rake_namespace, in the Ruby code:
|
177
|
+
|
178
|
+
Exodus.configure do |config|
|
179
|
+
config.rake_namespace = 'mongo'
|
180
|
+
end
|
181
|
+
|
182
|
+
Or in your Yaml file:
|
183
|
+
|
184
|
+
migration:
|
185
|
+
rake_namespace: 'mongo'
|
@@ -26,7 +26,7 @@ module Exodus
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def rake_namespace=(namespace)
|
29
|
-
@rake_namespace = namespace.to_s.empty? || namespace
|
29
|
+
@rake_namespace = namespace.to_s.empty? || namespace.end_with?(':') ? namespace.to_s : namespace + ':'
|
30
30
|
end
|
31
31
|
|
32
32
|
def migrate
|
@@ -103,7 +103,7 @@ module Exodus
|
|
103
103
|
self.status.direction = direction
|
104
104
|
|
105
105
|
# reset the status if the job is rerunnable and has already be completed
|
106
|
-
self.status
|
106
|
+
self.status.reset! if self.rerunnable_safe && completed?(direction)
|
107
107
|
self.status.execution_time = time_it { self.send(direction) }
|
108
108
|
self.status.last_succesful_completion = Time.now
|
109
109
|
end
|
data/lib/exodus/version.rb
CHANGED
@@ -57,6 +57,24 @@ describe Exodus::Migration do
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
60
|
+
|
61
|
+
class RerunnableMigrationTest < Exodus::Migration
|
62
|
+
def initialize(args = {})
|
63
|
+
super(args)
|
64
|
+
self.rerunnable_safe = true
|
65
|
+
end
|
66
|
+
|
67
|
+
def up
|
68
|
+
step("Creating new APIUser entity", 1) {UserSupport.first_or_create(:name =>'testor')}
|
69
|
+
end
|
70
|
+
|
71
|
+
def down
|
72
|
+
step("Droping APIUser entity", 0) do
|
73
|
+
user = UserSupport.first
|
74
|
+
user.destroy if user
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
60
78
|
end
|
61
79
|
|
62
80
|
subject { Migration_test1.first_or_create({}) }
|
@@ -87,6 +105,25 @@ describe Exodus::Migration do
|
|
87
105
|
subject.status.execution_time.should > 0
|
88
106
|
subject.status.message.should == 'Droping APIUser entity'
|
89
107
|
end
|
108
|
+
|
109
|
+
it "should run and rerun when the migration is rerunnable safe" do
|
110
|
+
RerunnableMigrationTest.collection.drop
|
111
|
+
UserSupport.collection.drop
|
112
|
+
|
113
|
+
migration = RerunnableMigrationTest.first_or_create({})
|
114
|
+
|
115
|
+
lambda{ migration.run('up')}.should change { UserSupport.count }.by(1)
|
116
|
+
migration.status.arguments.should be_empty
|
117
|
+
migration.status.current_status.should == 1
|
118
|
+
migration.status.direction.should == 'up'
|
119
|
+
migration.status.execution_time.should > 0
|
120
|
+
migration.status.last_succesful_completion.should
|
121
|
+
migration.status.message.should == 'Creating new APIUser entity'
|
122
|
+
|
123
|
+
UserSupport.first.destroy
|
124
|
+
UserSupport.count.should == 0
|
125
|
+
lambda{ migration.run('up')}.should change { UserSupport.count }.by(1)
|
126
|
+
end
|
90
127
|
end
|
91
128
|
|
92
129
|
describe "#failure=" do
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Exodus::MigrationStatus do
|
4
|
+
|
5
|
+
let(:migration) { Exodus::Migration.new }
|
6
|
+
subject {migration.status }
|
7
|
+
|
8
|
+
describe "New Oject" do
|
9
|
+
it "should have a status" do
|
10
|
+
subject.should_not be_nil
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#reset!" do
|
15
|
+
it "should reset the current status" do
|
16
|
+
time = Time.now
|
17
|
+
|
18
|
+
subject.message = "test"
|
19
|
+
subject.current_status = 1
|
20
|
+
subject.execution_time = 2
|
21
|
+
subject.last_succesful_completion = time
|
22
|
+
|
23
|
+
subject.message.should == "test"
|
24
|
+
subject.current_status.should == 1
|
25
|
+
subject.execution_time.should == 2
|
26
|
+
subject.last_succesful_completion.to_i.should == time.to_i
|
27
|
+
|
28
|
+
subject.reset!
|
29
|
+
|
30
|
+
subject.message.should == nil
|
31
|
+
subject.current_status.should == 0
|
32
|
+
subject.execution_time.should == 0
|
33
|
+
subject.last_succesful_completion.should == nil
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/tasks/exodus.rake
CHANGED
@@ -33,7 +33,7 @@ namespace Exodus.configuration.rake_namespace + 'db' do
|
|
33
33
|
desc "Show which migrations will be run when calling 'rake db:migrate'"
|
34
34
|
task :show => :require_env do
|
35
35
|
migrations = Exodus::Migration.load_all(Exodus.migrations_info.migrate)
|
36
|
-
puts "List of all the migrations that will be executed by running 'rake db:
|
36
|
+
puts "List of all the migrations that will be executed by running 'rake db:migrate#{" STEP=#{step}" if step}': \n\n"
|
37
37
|
|
38
38
|
migrations_info = Exodus::sort_and_run_migrations('up', migrations, step, true)
|
39
39
|
puts migrations_info.empty? ? "There is no new migrations to migrate." : migrations_info
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exodus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-12-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mongo_mapper
|
@@ -103,6 +103,7 @@ files:
|
|
103
103
|
- lib/exodus/version.rb
|
104
104
|
- spec/exodus/exodus_spec.rb
|
105
105
|
- spec/exodus/migration_spec.rb
|
106
|
+
- spec/exodus/migration_status_spec.rb
|
106
107
|
- spec/spec_helper.rb
|
107
108
|
- spec/support/config.yml
|
108
109
|
- spec/support/user_support.rb
|
@@ -135,6 +136,7 @@ summary: Exodus uses mongomapper to provide a complete migration framework
|
|
135
136
|
test_files:
|
136
137
|
- spec/exodus/exodus_spec.rb
|
137
138
|
- spec/exodus/migration_spec.rb
|
139
|
+
- spec/exodus/migration_status_spec.rb
|
138
140
|
- spec/spec_helper.rb
|
139
141
|
- spec/support/config.yml
|
140
142
|
- spec/support/user_support.rb
|