dazuma/activerecord-postgis-adapter — pull request #37 by dimroc (2012-11-15 02:31:08+00:00)
Title: Support postgis extension postgis_topology in Database.yml 

Support the following database.yml so topology extensions are automatically created with db:

```yaml
defaults: &defaults
adapter: postgis
encoding: unicode
pool: 5
postgis_extension: postgis,postgis_topology
schema_search_path: public,topology
# Intentionally left off postgis, see below.

development:
database: database_development
<<: *defaults

test:
database: database_test
<<: *defaults

production:
database: database_production
<<: *defaults

```

Before, it would attempt to create all extensions in the 'postgis' schema or, if no postgis schema exists, the last schema listed. The postgis_topology extension however requires the 'topology' schema.

```yaml
schema_search_path: public,topology
# Intentionally left off postgis, see below.
```
The above line was done as such because the `CREATE EXTENSION postgis_topology` creates all functions assuming the postgis types are in the public schema, not the postgis schema (ie: geometry not postgis.geometry). This means that if you use the default below

```yaml
schema_search_path: public,postgis,topology
```
you will need to cast every `postgis.geometry` to `geometry` in your sql when using the topology functions:

```sql
-- with postgis schema
SELECT st_simplify(geometry, 100) FROM regions;

-- ERROR: function st_simplify(postgis.geometry, integer) does not exist
-- LINE 1: SELECT st_simplify(geometry, 100) FROM regions LIMIT 1;
-- ^
-- HINT: No function matches the given name and argument types. You might need to add explicit type casts.

SELECT st_simplify(ST_GeomFromEWKB(geometry), 100) FROM regions;
```

Gets annoying.