我有一个带有PostGIS数据库的rails应用程序,它运行在码头容器中。我使用多租户公寓和activerecord postgis-适配器从ActiveRecord访问PostGIS地理空间数据库特性。正如公寓文档所建议的那样,我已经在shared_extentions
模式中安装了shared_extentions
。当我试图在geoserver中配置数据存储时,我会得到以下错误:
Error creating data store, check the parameters. Error message: Unable to obtain connection: ERROR: function postgis_lib_version() does not exist Hint: No function matches the given name and argument types. You might need to add explicit type casts. Position: 8
Geoserver数据存储连接参数:
host: app-db
port: 5432
database: app_development
schema: shared_extensions
user:
passwd:
database.yml
default: &default
adapter: postgis
postgis_schema: shared_extensions
schema_search_path: public, shared_extensions
encoding: unicode
database: app_development
host: app-db
username:
password:
lib/tasks/db_enhancements.rake
namespace :db do
desc 'Also create shared_extensions Schema'
task :extensions => :environment do
# Create Schema
ActiveRecord::Base.connection.execute 'CREATE SCHEMA IF NOT EXISTS shared_extensions;'
# Enable Hstore
ActiveRecord::Base.connection.execute 'CREATE EXTENSION IF NOT EXISTS HSTORE SCHEMA shared_extensions;'
# Enable Postgis
ActiveRecord::Base.connection.execute 'CREATE EXTENSION IF NOT EXISTS postgis SCHEMA shared_extensions;'
# Enable UUID-OSSP
ActiveRecord::Base.connection.execute 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp" SCHEMA shared_extensions;'
# Grant usage to public
ActiveRecord::Base.connection.execute 'GRANT usage ON SCHEMA shared_extensions to public;'
end
end
我还在pgAdmin上用SELECT shared_extensions.postgis_version()
试用了它,它运行得很好:
2.3 USE_GEOS=1 USE_PROJ=1 USE_STATS=1
但是,当然,当我运行SELECT postgis_version()
时,我得到:
ERROR: function postgis_version() does not exist
LÍNEA 1: SELECT postgis_version()
^
SUGERENCIA: No function matches the given name and argument types. You might need to add explicit type casts.
SQL state: 42883
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
Character: 8
发布于 2020-07-30 12:37:35
GeoServer希望PostGIS安装在公共模式中,不会将shared_extensions
放在其postgis函数的前面。如果您想要这样做,那么您需要将shared_extensions
添加到搜索路径中,以便GeoServer能够找到它需要的函数。
ALTER DATABASE mydb SET 'search_path' = public,shared_extension;
有关如何将postgis移动到不同架构的详细信息,请参阅此备注。
https://stackoverflow.com/questions/63140216
复制相似问题