From 7b330655899417c144a58b0c86958cb4a33ae168 Mon Sep 17 00:00:00 2001 From: Andrew Goodnough Date: Fri, 22 May 2015 17:19:04 -0500 Subject: [PATCH] Runs annotate on 'rake db:rollback' too --- lib/tasks/migrate.rake | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/tasks/migrate.rake b/lib/tasks/migrate.rake index 2935213bc..5b334c0ed 100644 --- a/lib/tasks/migrate.rake +++ b/lib/tasks/migrate.rake @@ -2,20 +2,22 @@ # (They are not used to build annotate itself.) # Append annotations to Rake tasks for ActiveRecord, so annotate automatically gets -# run after doing db:migrate. +# run after doing db:migrate. # Unfortunately it relies on ENV for options; it'd be nice to be able to set options # in a per-project config file so this task can read them. namespace :db do - task :migrate do - Annotate::Migration.update_annotations - end + [:migrate, :rollback].each do |cmd| + task cmd do + Annotate::Migration.update_annotations + end - namespace :migrate do - [:change, :up, :down, :reset, :redo].each do |t| - task t do - Annotate::Migration.update_annotations + namespace cmd do + [:change, :up, :down, :reset, :redo].each do |t| + task t do + Annotate::Migration.update_annotations + end end - end + end end end @@ -26,7 +28,7 @@ module Annotate def self.update_annotations unless @@working || (ENV['skip_on_db_migrate'] =~ /(true|t|yes|y|1)$/i) @@working = true - Rake::Task['annotate_models'].invoke + Rake::Task['annotate_models'].invoke end end end