Skip to content

Commit 1ee47e5

Browse files
committed
Merge pull request #249 from agoodno/run-on-rollback
Runs annotate on 'rake db:rollback' too
2 parents 0146ee7 + 7b33065 commit 1ee47e5

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

lib/tasks/migrate.rake

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,22 @@
22
# (They are not used to build annotate itself.)
33

44
# Append annotations to Rake tasks for ActiveRecord, so annotate automatically gets
5-
# run after doing db:migrate.
5+
# run after doing db:migrate.
66
# Unfortunately it relies on ENV for options; it'd be nice to be able to set options
77
# in a per-project config file so this task can read them.
88
namespace :db do
9-
task :migrate do
10-
Annotate::Migration.update_annotations
11-
end
9+
[:migrate, :rollback].each do |cmd|
10+
task cmd do
11+
Annotate::Migration.update_annotations
12+
end
1213

13-
namespace :migrate do
14-
[:change, :up, :down, :reset, :redo].each do |t|
15-
task t do
16-
Annotate::Migration.update_annotations
14+
namespace cmd do
15+
[:change, :up, :down, :reset, :redo].each do |t|
16+
task t do
17+
Annotate::Migration.update_annotations
18+
end
1719
end
18-
end
20+
end
1921
end
2022
end
2123

@@ -26,7 +28,7 @@ module Annotate
2628
def self.update_annotations
2729
unless @@working || (ENV['skip_on_db_migrate'] =~ /(true|t|yes|y|1)$/i)
2830
@@working = true
29-
Rake::Task['annotate_models'].invoke
31+
Rake::Task['annotate_models'].invoke
3032
end
3133
end
3234
end

0 commit comments

Comments
 (0)