Commit c479e5af by Cuong Tran

Merge pull request #254 from Foap/fix/invoke-options-on-migrations

Invoke get options task before annotating migrations
parents ce188d3e 938ed541
...@@ -29,7 +29,7 @@ module Annotate ...@@ -29,7 +29,7 @@ module Annotate
:timestamp, :exclude_serializers, :classified_sort, :show_foreign_keys, :timestamp, :exclude_serializers, :classified_sort, :show_foreign_keys,
] ]
OTHER_OPTIONS=[ OTHER_OPTIONS=[
:ignore_columns :ignore_columns, :skip_on_db_migrate
] ]
PATH_OPTIONS=[ PATH_OPTIONS=[
:require, :model_dir :require, :model_dir
......
...@@ -2,20 +2,21 @@ ...@@ -2,20 +2,21 @@
# (They are not used to build annotate itself.) # (They are not used to build annotate itself.)
# Append annotations to Rake tasks for ActiveRecord, so annotate automatically gets # 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 namespace :db do
task :migrate do task :migrate do
Rake::Task['set_annotation_options'].invoke
Annotate::Migration.update_annotations Annotate::Migration.update_annotations
end end
namespace :migrate do namespace :migrate do
[:change, :up, :down, :reset, :redo].each do |t| [:change, :up, :down, :reset, :redo].each do |t|
task t do task t do
Annotate::Migration.update_annotations Rake::Task['set_annotation_options'].invoke
Annotate::Migration.update_annotations
end end
end end
end end
end end
...@@ -24,9 +25,9 @@ module Annotate ...@@ -24,9 +25,9 @@ module Annotate
@@working = false @@working = false
def self.update_annotations 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 @@working = true
Rake::Task['annotate_models'].invoke Rake::Task['annotate_models'].invoke
end end
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