health_monitor 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{health_monitor}
8
- s.version = "0.1.3"
8
+ s.version = "0.1.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Blythe Dunham"]
@@ -2,11 +2,33 @@ module HealthMonitor
2
2
  module BuiltInChecks
3
3
  protected
4
4
 
5
+ # Check the schema and sort by casted version number
6
+ def sorted_schema_check; schema_check(:cast => true); end
7
+
5
8
  # Check the schema version
6
- def schema_check
7
- version = ActiveRecord::Base.connection.select_value(
8
- 'select version from schema_migrations order by version limit 1'
9
- )
9
+ # === Options
10
+ # <tt> :sql </tt> - the sql to use for the schema check
11
+ # <tt> :cast </tt> - cast the version to integer. Use for mysql non timestamped migrations if collation is not set.
12
+ # <tt> :order </tt> - the order by sql for selecting the current version
13
+ # <tt> :table </tt> - the table name. Defaults to schema_migrations.
14
+ def schema_check( options = {} )
15
+
16
+ sql = options[:sql]
17
+ sql||= begin
18
+ order_sql = if options[:order]
19
+ options[:order]
20
+ elsif options[:cast] ||
21
+ (!ActiveRecord::Base.timestamped_migrations && ActiveRecord::Base.connection.is_a?(ActiveRecord::ConnectionAdapters::MysqlAdapter))
22
+ "CAST(version as unsigned) DESC"
23
+ else
24
+ "version DESC"
25
+ end
26
+ table = options[:table] || (Rails::VERSION::STRING >= '2.1.0' ? 'schema_migrations' : 'schema_info')
27
+
28
+ options[:sql] || "select version from #{table} order by #{order_sql} LIMIT 1"
29
+ end
30
+
31
+ version = ActiveRecord::Base.connection.select_value( sql )
10
32
 
11
33
  {
12
34
  :status => :success,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: health_monitor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blythe Dunham