record migration name in marginalia comment

test plan:
 * add migration to your marginalia.yml (or copy over the example
   yml)
 * run a migration
 * check your logs - ensure the migration name is in the
   marginalia comment

Change-Id: I3a9f5163951a40904f1f4fe0d1c5c359dbabb25d
Reviewed-on: https://gerrit.instructure.com/50042
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Jenkins
QA-Review: August Thornton <august@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
Cody Cutrer 2015-03-09 10:33:18 -06:00
parent e511ec8a50
commit ce19a6ff7b
3 changed files with 6 additions and 1 deletions

View File

@ -1256,6 +1256,9 @@ module Migrator
def execute_migration_in_transaction(migration, direct)
old_in_migration, ActiveRecord::Base.in_migration = ActiveRecord::Base.in_migration, true
if defined?(Marginalia)
old_migration_name, Marginalia::Comment.migration = Marginalia::Comment.migration, migration.name
end
if down? && !Rails.env.test? && !$confirmed_migrate_down
require 'highline'
if HighLine.new.ask("Revert migration #{migration.name} (#{migration.version}) ? [y/N/a] > ") !~ /^([ya])/i
@ -1267,6 +1270,7 @@ module Migrator
super
ensure
ActiveRecord::Base.in_migration = old_in_migration
Marginalia::Comment.migration = old_migration_name if defined?(Marginalia)
end
end
ActiveRecord::Migrator.prepend(Migrator)

View File

@ -9,7 +9,7 @@ if config[:components].present?
module Marginalia
module Comment
class << self
attr_accessor :rake_task
attr_accessor :migration, :rake_task
def context_id
RequestContextGenerator.request_id

View File

@ -11,6 +11,7 @@
# - controller
# - action
# - job_tag
# - migration
# - rake_task
# - hostname
# - pid