Commit c03ba451 by Ryan Wilcox

option to control if should run annotate on db:migrate. Only tested with…

option to control if should run annotate on db:migrate. Only tested with annotate_models as a plugin, not as a gem. To control this option in your rails environment declare a module ANNOTATE_MODELS_PREFS with the constant UPDATE_ON_MIGRATE = false
parent 6049ee1f
......@@ -5,15 +5,32 @@
# 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.
def run_annotate_models?
update_on_migrate = true
(defined? ANNOTATE_MODELS_PREFS::UPDATE_ON_MIGRATE) &&
(!ANNOTATE_MODELS_PREFS::UPDATE_ON_MIGRATE.nil?) ?
ANNOTATE_MODELS_PREFS::UPDATE_ON_MIGRATE : true
end
namespace :db do
task :migrate do
if run_annotate_models?
Annotate::Migration.update_annotations
end
end
task :update => [:migrate] do
Annotate::Migration.update_annotations
end
namespace :migrate do
[:up, :down, :reset, :redo].each do |t|
task t do
Annotate::Migration.update_annotations
if run_annotate_models?
Annotate::Migration.update_annotations
end
end
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment