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 +1 -1
- data/health_monitor.gemspec +1 -1
- data/lib/health_monitor/built_in_checks.rb +26 -4
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.4
|
data/health_monitor.gemspec
CHANGED
@@ -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
|
-
|
7
|
-
|
8
|
-
|
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,
|