2021-06-08 01:23:25 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module Database
|
|
|
|
module Migrations
|
|
|
|
module Observers
|
|
|
|
class QueryLog < MigrationObserver
|
|
|
|
def before
|
|
|
|
@logger_was = ActiveRecord::Base.logger
|
2021-11-18 22:05:49 +05:30
|
|
|
file_path = File.join(output_dir, "#{observation.version}_#{observation.name}.log")
|
2021-10-27 15:23:28 +05:30
|
|
|
@logger = Logger.new(file_path)
|
2021-06-08 01:23:25 +05:30
|
|
|
ActiveRecord::Base.logger = @logger
|
|
|
|
end
|
|
|
|
|
|
|
|
def after
|
|
|
|
ActiveRecord::Base.logger = @logger_was
|
|
|
|
@logger.close
|
|
|
|
end
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
def record
|
|
|
|
# no-op
|
2021-06-08 01:23:25 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|