diff --git a/lib/annotate.rb b/lib/annotate.rb index 7c6072a39..15e4b3216 100755 --- a/lib/annotate.rb +++ b/lib/annotate.rb @@ -29,7 +29,7 @@ module Annotate :timestamp, :exclude_serializers, :classified_sort, :show_foreign_keys, ] OTHER_OPTIONS=[ - :ignore_columns + :ignore_columns, :skip_on_db_migrate ] PATH_OPTIONS=[ :require, :model_dir diff --git a/lib/tasks/migrate.rake b/lib/tasks/migrate.rake index 2935213bc..410c4a423 100644 --- a/lib/tasks/migrate.rake +++ b/lib/tasks/migrate.rake @@ -2,20 +2,21 @@ # (They are not used to build annotate itself.) # Append annotations to Rake tasks for ActiveRecord, so annotate automatically gets -# 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. +# run after doing db:migrate. + namespace :db do task :migrate do + Rake::Task['set_annotation_options'].invoke Annotate::Migration.update_annotations end namespace :migrate do [:change, :up, :down, :reset, :redo].each do |t| task t do - Annotate::Migration.update_annotations + Rake::Task['set_annotation_options'].invoke + Annotate::Migration.update_annotations end - end + end end end @@ -24,9 +25,9 @@ module Annotate @@working = false def self.update_annotations - unless @@working || (ENV['skip_on_db_migrate'] =~ /(true|t|yes|y|1)$/i) + unless @@working || Annotate.skip_on_migration? @@working = true - Rake::Task['annotate_models'].invoke + Rake::Task['annotate_models'].invoke end end end