class OkComputer::SequelCheck
Constants
- ConnectionFailed
Attributes
migration_directory[R]
Public Class Methods
new(options={})
click to toggle source
Public: Initialize the SequelCheck
with the database and/or the migration_directory.
Defaults to Sequel:Model.db and ‘db/migration’ respectively. “database” option can be a Proc so that Sequel can be instantiated later in the boot process.
# File lib/ok_computer/built_in_checks/sequel_check.rb, line 9 def initialize(options={}) @database = options[:database] || -> { ::Sequel::Model.db } @migration_directory = options[:migration_directory] || 'db/migrate' end
Public Instance Methods
check()
click to toggle source
Public: Return the schema version of the database
# File lib/ok_computer/built_in_checks/sequel_check.rb, line 15 def check mark_message "Schema is #{'not ' unless is_current?}up to date" rescue ConnectionFailed => e mark_failure mark_message "Error: '#{e}'" end
database()
click to toggle source
# File lib/ok_computer/built_in_checks/sequel_check.rb, line 22 def database @database.is_a?(Proc) ? @database.call : @database end
is_current?()
click to toggle source
Public: The scema version of the app’s database
Returns a String with the version number
# File lib/ok_computer/built_in_checks/sequel_check.rb, line 29 def is_current? ::Sequel.extension(:migration) ::Sequel::Migrator.is_current?(database, migration_directory) rescue => e raise ConnectionFailed, e end