Method: DBGeni::Migrator::Oracle#migration_errors

Defined in:
lib/dbgeni/migrators/oracle.rb

#migration_errorsObject

def rollback(migration, force=nil) end

[View source]

16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/dbgeni/migrators/oracle.rb', line 16

def migration_errors
  has_errors = false
  buffer = []

  begin
    File.open(@logfile, 'r').each_line do |l|
      buffer.push l
      if buffer.length > 10
        buffer.shift
      end
      if !has_errors && l =~ /^ERROR at line/
        has_errors = true
        next
      end
      # After we find the ERROR at line, the next line contains the error
      # message, so we just want to consume it and then exit.
      # The line we care about will be in the buffer, so just break and join
      # the buffer.
      if has_errors
        break
      end
    end
  rescue Errno::ENOENT
    # assume this means the log was never written as, generally because
    # sqlplus didn't connect to Oracle. In this case do nothing
  end
  buffer.join("")
end