Class: Rack::ECG::Check::MigrationVersion

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/ecg/check/migration_version.rb

Instance Method Summary collapse

Constructor Details

#initializeObject

Returns the latest applied ActiveRecord migration in the default database.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rack/ecg/check/migration_version.rb', line 9

class MigrationVersion
  def result
    value = ""
    status = Status::OK
    begin
      if defined?(ActiveRecord)
        connection = ActiveRecord::Base.connection
        value = connection.select_value("select max(version) from schema_migrations")
      else
        status = Status::ERROR
        value = "ActiveRecord not found"
      end
    rescue => e
      status = Status::ERROR
      value = e.message
    end

    Result.new(:migration_version, status, value)
  end
end

Instance Method Details

#resultObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rack/ecg/check/migration_version.rb', line 10

def result
  value = ""
  status = Status::OK
  begin
    if defined?(ActiveRecord)
      connection = ActiveRecord::Base.connection
      value = connection.select_value("select max(version) from schema_migrations")
    else
      status = Status::ERROR
      value = "ActiveRecord not found"
    end
  rescue => e
    status = Status::ERROR
    value = e.message
  end

  Result.new(:migration_version, status, value)
end