Skip to content

Commit

Permalink
Merge branch 'master' of github.com:nofxx/postgis_adapter
Browse files Browse the repository at this point in the history
* 'master' of github.com:nofxx/postgis_adapter:
  Adding support to create a Test PostGIS database; from git://github.com/melriffe/spatial_adapter.git
  • Loading branch information
nofxx committed Sep 20, 2010
2 parents 8d71bd9 + 84c8428 commit 0b6b1e3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.rdoc
Expand Up @@ -37,6 +37,15 @@ If you are using Spatial Adapter, *remove it first*.
gem install postgis_adapter -v 0.7.8


====== PostGIS SQL Scripts
This is only for PostgreSQL databases:

Place the following scripts in a folder named 'spatial' under the 'db' folder; For example:
RAILS_ROOT/db/spatial/lwpostgis.sql
RAILS_ROOT/db/spatial/spatial_ref_sys

These will be used when creating the Test database when running the Rake Test tasks. These scripts should have been installed when the PostGIS libraries were installed. Online reference: http://postgis.refractions.net/


== How to Use

Expand Down
11 changes: 11 additions & 0 deletions lib/postgis_adapter.rb
Expand Up @@ -102,6 +102,17 @@ def self.sanitize_sql_hash_for_conditions(attrs, table_name = quoted_table_name)

include SpatialAdapter

# SCHEMA STATEMENTS ========================================

alias :original_recreate_database :recreate_database
def recreate_database(configuration, enc_option)
`dropdb -U "#{configuration["test"]["username"]}" #{configuration["test"]["database"]}`
`createdb #{enc_option} -U "#{configuration["test"]["username"]}" #{configuration["test"]["database"]}`
`createlang -U "#{configuration["test"]["username"]}" plpgsql #{configuration["test"]["database"]}`
`psql -d #{configuration["test"]["database"]} -f db/spatial/lwpostgis.sql`
`psql -d #{configuration["test"]["database"]} -f db/spatial/spatial_ref_sys.sql`
end

alias :original_native_database_types :native_database_types
def native_database_types
original_native_database_types.update(geometry_data_types)
Expand Down

0 comments on commit 0b6b1e3

Please sign in to comment.