简体   繁体   中英

activerecord-postgis-adapter v2 do not create separate schema in Rails 4

I'm updating Rails 3.2 project with activerecord-postgis-adapter (0.6.5) to Rails 4.0 (ar-postgis-adapter 2.2.1).

When I try to create test db via rake db:create created db has only one public schema with spatial_ref_sys table and PostGIS functions.

When I try to clone development db to test I have errors on tables with postgis columns: type "postgis.geography" does not exist .

From source code I discovered that gem accepts new param postgis_schema from connection configuration (this param do not specified in readme). In early versions separate schema name was extracted from schema_search_path . I specified it but nothing was changed.

This is an issue in this version of activerecord-postgis-adapter because of SQL-schema. To clone db correctly you need to dump and load non-sql schema:

rake db:schema:dump
rake db:test:load_schema

Or add this task:

Rake::Task["db:test:clone"].clear

namespace :db do
  namespace :test do
    task :clone => [:environment] do
      puts 'Dumping development schema...'
      Rake::Task['db:schema:dump'].invoke

      puts 'Loading development schema into test database...'
      Rake::Task['db:test:load_schema'].invoke
    end
  end
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM