Skip to content

Invoke get options task before annotating migrations #254

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/annotate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 8 additions & 7 deletions lib/tasks/migrate.rake
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down