exodus 1.1.0 → 1.1.1
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/CHANGELOG.md +5 -0
- data/lib/exodus.rb +1 -1
- data/lib/exodus/helpers/rake_helper.rb +14 -0
- data/lib/exodus/migrations/migration.rb +8 -0
- data/lib/exodus/version.rb +1 -1
- data/spec/exodus/exodus_spec.rb +21 -11
- data/tasks/exodus.rake +10 -17
- metadata +83 -54
- checksums.yaml +0 -7
data/CHANGELOG.md
CHANGED
data/lib/exodus.rb
CHANGED
@@ -49,7 +49,7 @@ module Exodus
|
|
49
49
|
runnable_migrations = migrations_info.map do |migration_class, args|
|
50
50
|
migration = instanciate_migration(migration_class, args)
|
51
51
|
migration if migration.is_runnable?(direction)
|
52
|
-
end.compact
|
52
|
+
end.compact.uniq
|
53
53
|
|
54
54
|
step ? runnable_migrations.shift(step.to_i) : runnable_migrations
|
55
55
|
end
|
@@ -128,6 +128,14 @@ module Exodus
|
|
128
128
|
"#{self.class}: #{self.status.arguments}"
|
129
129
|
end
|
130
130
|
|
131
|
+
def eql?(other_migration)
|
132
|
+
self.class == other_migration.class && self.status.arguments == other_migration.status.arguments
|
133
|
+
end
|
134
|
+
|
135
|
+
def hash
|
136
|
+
self.class.hash ^ self.status.arguments.hash
|
137
|
+
end
|
138
|
+
|
131
139
|
protected
|
132
140
|
|
133
141
|
# Executes a given block if the status has not being processed
|
data/lib/exodus/version.rb
CHANGED
data/spec/exodus/exodus_spec.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Exodus do
|
4
|
+
before do
|
5
|
+
Exodus::Migration.collection.drop
|
6
|
+
end
|
7
|
+
|
4
8
|
describe "sort_migrations" do
|
5
9
|
before do
|
6
10
|
class Migration_test4 < Exodus::Migration; end
|
@@ -89,8 +93,7 @@ describe Exodus do
|
|
89
93
|
describe "with a valid migration" do
|
90
94
|
it "should successfully create the migration" do
|
91
95
|
migration = Exodus.instanciate_migration(Migration_test6, {})
|
92
|
-
lambda{ Exodus.run_one_migration(migration, 'up')}.should
|
93
|
-
change {Exodus::Migration}.by(1)
|
96
|
+
lambda{ Exodus.run_one_migration(migration, 'up')}.should change(Exodus::Migration, :count).by(1)
|
94
97
|
end
|
95
98
|
end
|
96
99
|
|
@@ -98,13 +101,11 @@ describe Exodus do
|
|
98
101
|
let(:migration) {Exodus.instanciate_migration(Migration_test7, {})}
|
99
102
|
|
100
103
|
it "should raise an error" do
|
101
|
-
lambda {Exodus.run_one_migration(migration, 'up')}.should
|
102
|
-
raise_error(StandardError)
|
104
|
+
lambda {Exodus.run_one_migration(migration, 'up')}.should raise_error(StandardError)
|
103
105
|
end
|
104
106
|
|
105
|
-
it "should create the migration" do
|
106
|
-
lambda {Exodus.run_one_migration(migration, 'up')}.should
|
107
|
-
change {Exodus::Migration}.by(1)
|
107
|
+
it "should still create the migration" do
|
108
|
+
lambda {Exodus.run_one_migration(migration, 'up') rescue nil}.should change(Exodus::Migration, :count).by(1)
|
108
109
|
end
|
109
110
|
end
|
110
111
|
end
|
@@ -115,8 +116,7 @@ describe Exodus do
|
|
115
116
|
migration = Exodus.instanciate_migration(Migration_test6, {})
|
116
117
|
Exodus.run_one_migration(migration, 'up')
|
117
118
|
|
118
|
-
lambda {Exodus.run_one_migration(migration, 'up')}.should
|
119
|
-
change {Exodus::Migration}.by(0)
|
119
|
+
lambda {Exodus.run_one_migration(migration, 'up')}.should change(Exodus::Migration, :count).by(0)
|
120
120
|
end
|
121
121
|
end
|
122
122
|
|
@@ -125,8 +125,7 @@ describe Exodus do
|
|
125
125
|
migration = Exodus.instanciate_migration(Migration_test7, {})
|
126
126
|
Exodus.run_one_migration(migration, 'up') rescue nil
|
127
127
|
|
128
|
-
lambda {Exodus.run_one_migration(migration, 'up')}.should
|
129
|
-
change {Exodus::Migration}.by(0)
|
128
|
+
lambda {Exodus.run_one_migration(migration, 'up') rescue nil}.should change(Exodus::Migration, :count).by(0)
|
130
129
|
end
|
131
130
|
end
|
132
131
|
end
|
@@ -194,6 +193,7 @@ describe Exodus do
|
|
194
193
|
UserSupport.create!({:name => "Thomas"})
|
195
194
|
end
|
196
195
|
end
|
196
|
+
|
197
197
|
class Migration_test10 < Exodus::Migration
|
198
198
|
@migration_number = 10
|
199
199
|
def up
|
@@ -247,6 +247,16 @@ describe Exodus do
|
|
247
247
|
end
|
248
248
|
end
|
249
249
|
|
250
|
+
it "should run only one time the same migration" do
|
251
|
+
migrations = [[Migration_test9, {}], [Migration_test9, {}]]
|
252
|
+
lambda {Exodus.sort_and_run_migrations('up', migrations)}.should change(Exodus::Migration, :count).by(1)
|
253
|
+
end
|
254
|
+
|
255
|
+
it "should run successfully only one time when specifying the step option" do
|
256
|
+
migrations = [[Migration_test9, {}], [Migration_test10, {}]]
|
257
|
+
lambda {Exodus.sort_and_run_migrations('up', migrations, 1)}.should change(Exodus::Migration, :count).by(1)
|
258
|
+
end
|
259
|
+
|
250
260
|
describe "Getting migration information" do
|
251
261
|
it "should successfully print the migrations information" do
|
252
262
|
migrations = [[Migration_test9, {}], [Migration_test10, {}]]
|
data/tasks/exodus.rake
CHANGED
@@ -1,19 +1,10 @@
|
|
1
1
|
require 'rake'
|
2
2
|
|
3
|
-
def time_it(task, &block)
|
4
|
-
puts "#{task} starting..."
|
5
|
-
start = Time.now
|
6
|
-
yield
|
7
|
-
puts "#{task} Done in (#{Time.now-start}s)!!"
|
8
|
-
end
|
9
|
-
|
10
|
-
def step
|
11
|
-
ENV['STEP']
|
12
|
-
end
|
13
|
-
|
14
3
|
task :require_env do
|
15
4
|
require 'csv'
|
16
5
|
require File.dirname(__FILE__) + '/../lib/exodus'
|
6
|
+
require File.dirname(__FILE__) + '/../lib/exodus/helpers/rake_helper'
|
7
|
+
include Exodus::RakeHelper
|
17
8
|
Exodus.load_migrations
|
18
9
|
end
|
19
10
|
|
@@ -44,7 +35,9 @@ namespace :db do
|
|
44
35
|
task :show => :require_env do
|
45
36
|
migrations = Exodus::Migration.load_all(Exodus.migrations_info.migrate)
|
46
37
|
puts "List of all the migrations that will be executed by running 'rake db:rollback#{" STEP=#{step}" if step}': \n\n"
|
47
|
-
|
38
|
+
|
39
|
+
migrations_info = Exodus::sort_and_run_migrations('up', migrations, step, true)
|
40
|
+
puts migrations_info.empty? ? "There is no new migrations to migrate." : migrations_info
|
48
41
|
end
|
49
42
|
|
50
43
|
desc "Manually migrates specified migrations (specify migrations or use config/migration.yml)"
|
@@ -56,8 +49,7 @@ namespace :db do
|
|
56
49
|
Exodus::Migration.load_custom(Exodus.migrations_info.migrate_custom)
|
57
50
|
end
|
58
51
|
|
59
|
-
migrations
|
60
|
-
Exodus::run_migrations('up', migrations)
|
52
|
+
Exodus::sort_and_run_migrations('up', migrations, step)
|
61
53
|
end
|
62
54
|
end
|
63
55
|
|
@@ -82,7 +74,9 @@ namespace :db do
|
|
82
74
|
task :show => :require_env do
|
83
75
|
migrations = Exodus::Migration.load_all(Exodus.migrations_info.migrate)
|
84
76
|
puts "List of all the migrations that will be executed by running 'rake db:rollback#{" STEP=#{step}" if step}': \n\n"
|
85
|
-
|
77
|
+
|
78
|
+
migrations_info = Exodus::sort_and_run_migrations('down', migrations, step, true)
|
79
|
+
puts migrations_info.empty? ? "There is no new migrations to rollback." : migrations_info
|
86
80
|
end
|
87
81
|
|
88
82
|
desc "Manually rolls the database back using specified migrations (specify migrations or use config/migration.yml)"
|
@@ -94,8 +88,7 @@ namespace :db do
|
|
94
88
|
Exodus::Migration.load_custom(Exodus.migrations_info.rollback_custom)
|
95
89
|
end
|
96
90
|
|
97
|
-
migrations
|
98
|
-
Exodus::run_migrations('down', migrations)
|
91
|
+
Exodus::sort_and_run_migrations('down', migrations, step)
|
99
92
|
end
|
100
93
|
end
|
101
94
|
end
|
metadata
CHANGED
@@ -1,62 +1,88 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: exodus
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.1
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
|
-
authors:
|
7
|
+
authors:
|
7
8
|
- Thomas Dmytryk
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2013-11-08 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
15
|
name: mongo_mapper
|
16
|
-
|
17
|
-
|
18
|
-
requirements:
|
19
|
-
-
|
20
|
-
-
|
21
|
-
|
22
|
-
version: "0"
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
23
22
|
type: :runtime
|
24
|
-
version_requirements: *id001
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: bson_ext
|
27
23
|
prerelease: false
|
28
|
-
|
29
|
-
|
30
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: bson_ext
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
31
38
|
type: :runtime
|
32
|
-
version_requirements: *id003
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: rspec
|
35
39
|
prerelease: false
|
36
|
-
|
37
|
-
|
38
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
39
54
|
type: :development
|
40
|
-
version_requirements: *id004
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rake
|
43
55
|
prerelease: false
|
44
|
-
|
45
|
-
|
46
|
-
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rake
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
47
70
|
type: :development
|
48
|
-
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
49
78
|
description: Exodus is a migration framework for MongoDb
|
50
|
-
email:
|
79
|
+
email:
|
51
80
|
- thomas@fanhattan.com
|
52
81
|
- thomas.dmytryk@supinfo.com
|
53
82
|
executables: []
|
54
|
-
|
55
83
|
extensions: []
|
56
|
-
|
57
84
|
extra_rdoc_files: []
|
58
|
-
|
59
|
-
files:
|
85
|
+
files:
|
60
86
|
- .gitignore
|
61
87
|
- .rspec
|
62
88
|
- .rvmrc
|
@@ -69,6 +95,7 @@ files:
|
|
69
95
|
- exodus.gemspec
|
70
96
|
- lib/exodus.rb
|
71
97
|
- lib/exodus/config/migration_info.rb
|
98
|
+
- lib/exodus/helpers/rake_helper.rb
|
72
99
|
- lib/exodus/helpers/text_formatter.rb
|
73
100
|
- lib/exodus/migrations/migration.rb
|
74
101
|
- lib/exodus/migrations/migration_error.rb
|
@@ -81,29 +108,31 @@ files:
|
|
81
108
|
- spec/support/user_support.rb
|
82
109
|
- tasks/exodus.rake
|
83
110
|
homepage: https://github.com/ThomasAlxDmy/Exodus
|
84
|
-
licenses:
|
111
|
+
licenses:
|
85
112
|
- MIT
|
86
|
-
metadata: {}
|
87
|
-
|
88
113
|
post_install_message:
|
89
114
|
rdoc_options: []
|
90
|
-
|
91
|
-
require_paths:
|
115
|
+
require_paths:
|
92
116
|
- lib
|
93
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
117
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
118
|
+
none: false
|
119
|
+
requirements:
|
120
|
+
- - ! '>='
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
none: false
|
125
|
+
requirements:
|
126
|
+
- - ! '>='
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
99
129
|
requirements: []
|
100
|
-
|
101
130
|
rubyforge_project:
|
102
|
-
rubygems_version:
|
131
|
+
rubygems_version: 1.8.23
|
103
132
|
signing_key:
|
104
|
-
specification_version:
|
133
|
+
specification_version: 3
|
105
134
|
summary: Exodus uses mongomapper to provide a complete migration framework
|
106
|
-
test_files:
|
135
|
+
test_files:
|
107
136
|
- spec/exodus/exodus_spec.rb
|
108
137
|
- spec/exodus/migration_spec.rb
|
109
138
|
- spec/spec_helper.rb
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 200e6321b65c9da53640570039104a3431d9b01c
|
4
|
-
data.tar.gz: 3bfc62dbf17cb4e149fb0e05099f6cf90cbd7f40
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 93a228768b22948e1aa9d0901aafe751d855f807af5c136fc5e198277412e6b7172acd48a009fd066317e4f3a209e08330d26195dd9d19a1b6fbcf56d34dbff2
|
7
|
-
data.tar.gz: 7312deffd0e3ab6347ea390ab0d8374f3be0365eda5043450ea152be159b5d9c9818b01161f43c18857f851d6114a1855a0159d15ef83d5b4a4e60203304b513
|