Skip to content

Commit c479e5a

Browse files
committed
Merge pull request #254 from Foap/fix/invoke-options-on-migrations
Invoke get options task before annotating migrations
2 parents ce188d3 + 938ed54 commit c479e5a

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

lib/annotate.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module Annotate
2929
:timestamp, :exclude_serializers, :classified_sort, :show_foreign_keys,
3030
]
3131
OTHER_OPTIONS=[
32-
:ignore_columns
32+
:ignore_columns, :skip_on_db_migrate
3333
]
3434
PATH_OPTIONS=[
3535
:require, :model_dir

lib/tasks/migrate.rake

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@
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.
6-
# Unfortunately it relies on ENV for options; it'd be nice to be able to set options
7-
# in a per-project config file so this task can read them.
5+
# run after doing db:migrate.
6+
87
namespace :db do
98
task :migrate do
9+
Rake::Task['set_annotation_options'].invoke
1010
Annotate::Migration.update_annotations
1111
end
1212

1313
namespace :migrate do
1414
[:change, :up, :down, :reset, :redo].each do |t|
1515
task t do
16-
Annotate::Migration.update_annotations
16+
Rake::Task['set_annotation_options'].invoke
17+
Annotate::Migration.update_annotations
1718
end
18-
end
19+
end
1920
end
2021
end
2122

@@ -24,9 +25,9 @@ module Annotate
2425
@@working = false
2526

2627
def self.update_annotations
27-
unless @@working || (ENV['skip_on_db_migrate'] =~ /(true|t|yes|y|1)$/i)
28+
unless @@working || Annotate.skip_on_migration?
2829
@@working = true
29-
Rake::Task['annotate_models'].invoke
30+
Rake::Task['annotate_models'].invoke
3031
end
3132
end
3233
end

0 commit comments

Comments
 (0)