Module: SafePgMigrations::Helpers::BlockingActivityFormatter

Included in:
BlockingActivityLogger
Defined in:
lib/safe-pg-migrations/helpers/blocking_activity_formatter.rb

Instance Method Summary collapse

Instance Method Details

#log_queries(queries) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/safe-pg-migrations/helpers/blocking_activity_formatter.rb', line 6

def log_queries(queries)
  if queries.empty?
    Logger.say 'Could not find any blocking query.', sub_item: true
  else
    Logger.say <<~MESSAGE.squish, sub_item: true
      Statement was being blocked by the following #{'query'.pluralize(queries.size)}:
    MESSAGE

    Logger.say '', sub_item: true
    output_blocking_queries(queries)
    Logger.say <<~MESSAGE.squish, sub_item: true
      Beware, some of those queries might run in a transaction. In this case the locking query might be located
      elsewhere in the transaction
    MESSAGE

    Logger.say '', sub_item: true
  end
end