migration_tools 0.1.0 → 0.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/README.rdoc +15 -2
- data/VERSION +1 -1
- data/lib/migration_tools/tasks.rb +18 -0
- data/migration_tools.gemspec +1 -1
- data/test/test_migration_tools.rb +12 -0
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -31,10 +31,23 @@ The names of the possible groups are predefined to avoid turning this solution i
|
|
31
31
|
|
32
32
|
== Commands
|
33
33
|
|
34
|
+
The list commands
|
35
|
+
|
34
36
|
$ rake db:migrate:list - shows pending migrations by group
|
35
|
-
$
|
37
|
+
$ rake db:migrate:list:before - shows pending migrations for the before group
|
38
|
+
$ rake db:migrate:list:during - shows pending migrations for the during group
|
39
|
+
$ rake db:migrate:list:after - shows pending migrations for the after group
|
40
|
+
$ rake db:migrate:list:change - shows pending migrations for the change group
|
41
|
+
|
42
|
+
The group commands
|
43
|
+
|
44
|
+
$ GROUP=before rake db:migrate:group - runs the migrations in the specified group
|
45
|
+
$ rake db:migrate:group:before - runs pending migrations for the before group
|
46
|
+
$ rake db:migrate:group:during - runs pending migrations for the during group
|
47
|
+
$ rake db:migrate:group:after - runs pending migrations for the after group
|
48
|
+
$ rake db:migrate:group:change - runs pending migrations for the change group
|
36
49
|
|
37
|
-
Note that rake db:migrate is entirely unaffected by this
|
50
|
+
Note that rake db:migrate is entirely unaffected by this.
|
38
51
|
|
39
52
|
== Contributing to migration_tools
|
40
53
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
@@ -6,6 +6,7 @@ module MigrationTools
|
|
6
6
|
def initialize
|
7
7
|
define_migrate_list
|
8
8
|
define_migrate_group
|
9
|
+
define_convenience_tasks
|
9
10
|
end
|
10
11
|
|
11
12
|
def group
|
@@ -61,6 +62,23 @@ module MigrationTools
|
|
61
62
|
end
|
62
63
|
end
|
63
64
|
|
65
|
+
def define_convenience_tasks
|
66
|
+
namespace :db do
|
67
|
+
namespace :migrate do
|
68
|
+
[ :list, :group ].each do |ns|
|
69
|
+
namespace ns do
|
70
|
+
[ :before, :during, :after, :change ].each do |migration_group|
|
71
|
+
task migration_group do
|
72
|
+
ENV['GROUP'] = migration_group.to_s
|
73
|
+
Rake::Task["db:migrate:#{ns}"].invoke
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
64
82
|
def notify(string, group = "")
|
65
83
|
if group.empty?
|
66
84
|
puts string
|
data/migration_tools.gemspec
CHANGED
@@ -65,6 +65,10 @@ class TestMigrationTools < Test::Unit::TestCase
|
|
65
65
|
def test_task_presence
|
66
66
|
assert Rake::Task["db:migrate:list"]
|
67
67
|
assert Rake::Task["db:migrate:group"]
|
68
|
+
assert Rake::Task["db:migrate:group:before"]
|
69
|
+
assert Rake::Task["db:migrate:group:during"]
|
70
|
+
assert Rake::Task["db:migrate:group:after"]
|
71
|
+
assert Rake::Task["db:migrate:group:change"]
|
68
72
|
end
|
69
73
|
|
70
74
|
def test_migrate_list_without_pending_without_group
|
@@ -131,4 +135,12 @@ class TestMigrationTools < Test::Unit::TestCase
|
|
131
135
|
end
|
132
136
|
end
|
133
137
|
|
138
|
+
def test_convenience_list_method
|
139
|
+
ActiveRecord::Migrator.expects(:new).returns(stub(:pending_migrations => proxies))
|
140
|
+
MigrationTools::Tasks.any_instance.expects(:notify).with("You have 2 pending migrations", "before").once
|
141
|
+
MigrationTools::Tasks.any_instance.expects(:notify).with(" 0 before Alpha").once
|
142
|
+
MigrationTools::Tasks.any_instance.expects(:notify).with(" 1 before Beta").once
|
143
|
+
|
144
|
+
Rake::Task["db:migrate:list:before"].invoke
|
145
|
+
end
|
134
146
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: migration_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Morten Primdahl
|