升级到Rails 4时的Postgis错误 [英] Postgis Error when upgrading to Rails 4

查看:248
本文介绍了升级到Rails 4时的Postgis错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我和我的团队目前正在维护阶段,我一直在忙于升级所有内容.上周,我将团队从PostgreSQL 9.1迁移到9.3,将PostGIS 1.5迁移到2.1,一切进展顺利.昨天,Rails团队提交了一个Rails 4升级请求,但我们的CI迅速拒绝了该请求.任何建议将不胜感激.

My team and I are going through a maintenance phase currently, and I've been busy upgrading everything. Last week I moved the team from PostgreSQL 9.1 to 9.3 and PostGIS 1.5 to 2.1 which all went smoothly. Yesterday, the Rails team submitted a Rails 4 upgrade pull request that our CI swiftly rejected. Any suggestions would be greatly appreciated.

尝试创建新的测试数据库时,出现以下Rails错误:

When attempting to create a new test database, I receive the following Rails error:

PG::RaiseException: ERROR:  PostGIS is already installed in schema 'public', uninstall it first : CREATE EXTENSION postgis SCHEMA public

一些规格:

  • Debian 7 Wheezy
  • PostgreSQL 9.3
  • PostGIS 2.1
  • Ruby 2.1.0
  • 路轨4

我的PostgreSQL/PostGIS安装步骤:

My PostgreSQL / PostGIS installation steps:

sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main" >> /etc/apt/sources.list'
wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
apt-get update -y

apt-get install postgresql-9.3-postgis-2.1

sudo -u postgres psql -c "CREATE USER xxadmin WITH PASSWORD 'xxpass';"
sudo -u postgres psql -c "ALTER USER xxadmin WITH SUPERUSER;"

sudo -u postgres psql -c "create database template_postgis with template = template1;"
sudo -u postgres psql -c "UPDATE pg_database SET datistemplate = TRUE where datname = 'template_postgis';"
sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.3/extension/postgis--2.1.2.sql
sudo -u postgres psql -d template_postgis -c "GRANT ALL ON geometry_columns TO xxadmin;"
sudo -u postgres psql -d template_postgis -c "GRANT ALL ON spatial_ref_sys TO xxadmin;"
sudo -u postgres psql -d template_postgis -c "VACUUM FREEZE;"
sudo -u postgres psql -c "ALTER DATABASE template_postgis OWNER TO xxadmin;"
sudo -u postgres psql -d template_postgis -c "ALTER VIEW geography_columns OWNER to xxadmin;"
sudo -u postgres psql -d template_postgis -c "ALTER TABLE geometry_columns OWNER to xxadmin;"
sudo -u postgres psql -d template_postgis -c "ALTER TABLE spatial_ref_sys OWNER to xxadmin;"

推荐答案

当前有几种不同方法可通过PostGIS在空间上启用PostgreSQL数据库:

There are currently a few different methods to spatially enable a PostgreSQL database with PostGIS:

  1. 使用DDL命令 CREATE EXTENSION postgis; . 最简单和推荐.
  2. 使用启用脚本.此方法有多个步骤,如果您有特定要求(例如,禁止使用栅格支持),则很有用.
  3. 使用模板(例如template_postgis)数据库.这对于设置具有相似功能的多个数据库可能很有用.有时预安装了template_postgis,有时则需要创建它.
  1. Using the DDL command CREATE EXTENSION postgis;. Easiest and recommended.
  2. Using enabler scripts. This method has multiple steps, is useful if you have specific requirements, for example disallowing raster support.
  3. Using a template (e.g. template_postgis) database. This could be useful to setup multiple databases that have similar features. Sometimes template_postgis is pre-installed, other times you would need to create this.

这篇关于升级到Rails 4时的Postgis错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆