[#1879] Set DataStore to legacy mode when using PostgreSQL < 9.x

Up until now the user had to actively set legacy mode when running PG
8.x, and if not you could end up with the full datastore running on an
old postgres version. Features like the SQL search are not properly
supported on these versions, so we need to explicitly disable them when
running on PG 8.x, by setting `legacy_mode` to True.

The current behaviour is that legacy mode will be activated if
`ckan.datastore.read_url` is not present in the configuration and/or
postgres < 9.x.
[#1879] Fix tests

The travis setup explicitly removes the `ckan.datastore.read_url`
setting when running the tests, so we need to use a dummy one.

Also some refactoring
Merge branch '1879-datastore-legacy-mode'