def schema_check( options = {} )

      sql = options[:sql]
      sql||= begin
        order_sql = if options[:order]
          options[:order]
        elsif options[:cast] || 
          (!ActiveRecord::Base.timestamped_migrations && ActiveRecord::Base.connection.is_a?(ActiveRecord::ConnectionAdapters::MysqlAdapter))
          "CAST(version as unsigned) DESC"
        else
          "version DESC"
        end
        table = options[:table] || (Rails::VERSION::STRING >= '2.1.0' ? 'schema_migrations' : 'schema_info')

        options[:sql] || "select version from #{table} order by #{order_sql} LIMIT 1"
      end
      
      version    = ActiveRecord::Base.connection.select_value( sql )

      {
        :status       => :success,
        :message      => "Schema version #{version}",
        :description  => 'Check database connection and schema'
      }
    end
def schema_check( options = {} )

      sql = options[:sql]
      sql||= begin
        order_sql = if options[:order]
          options[:order]
        elsif options[:cast] || 
          (!ActiveRecord::Base.timestamped_migrations && ActiveRecord::Base.connection.is_a?(ActiveRecord::ConnectionAdapters::MysqlAdapter))
          "CAST(version as unsigned) DESC"
        else
          "version DESC"
        end
        table = options[:table] || (Rails::VERSION::STRING >= '2.1.0' ? 'schema_migrations' : 'schema_info')

        options[:sql] || "select version from #{table} order by #{order_sql} LIMIT 1"
      end
      
      version    = ActiveRecord::Base.connection.select_value( sql )

      {
        :status       => :success,
        :message      => "Schema version #{version}",
        :description  => 'Check database connection and schema'
      }
    end
Check the schema version
 === Options
  <tt> :sql </tt> - the sql to use for the schema check
  <tt> :cast </tt> - cast the version to integer. Use for mysql non timestamped migrations if collation is not set.
  <tt> :order </tt> - the order by sql for selecting the current version
  <tt> :table </tt> - the table name. Defaults to schema_migrations.