Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 4 升级到Rails 4时出现Postgis错误_Ruby On Rails 4_Postgis_Postgresql 9.3 - Fatal编程技术网

Ruby on rails 4 升级到Rails 4时出现Postgis错误

Ruby on rails 4 升级到Rails 4时出现Postgis错误,ruby-on-rails-4,postgis,postgresql-9.3,Ruby On Rails 4,Postgis,Postgresql 9.3,我和我的团队目前正在经历一个维护阶段,我一直在忙着升级一切。上周,我将团队从PostgreSQL 9.1迁移到了9.3,PostGIS 1.5迁移到了2.1,这一切都进行得很顺利。昨天,Rails团队提交了Rails 4升级请求,我们的CI迅速拒绝了该请求。如有任何建议,将不胜感激 尝试创建新的测试数据库时,我收到以下Rails错误: PG::RaiseException: ERROR: PostGIS is already installed in schema 'public', unin

我和我的团队目前正在经历一个维护阶段,我一直在忙着升级一切。上周,我将团队从PostgreSQL 9.1迁移到了9.3,PostGIS 1.5迁移到了2.1,这一切都进行得很顺利。昨天,Rails团队提交了Rails 4升级请求,我们的CI迅速拒绝了该请求。如有任何建议,将不胜感激

尝试创建新的测试数据库时,我收到以下Rails错误:

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

  • Debian 7喘息
  • PostgreSQL 9.3
  • PostGIS 2.1
  • Ruby 2.1.0
  • 轨道4
我的PostgreSQL/PostGIS安装步骤:

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;"
目前有几种不同的方法可以在空间上启用PostgreSQL数据库和PostGIS:

  • 使用DDL命令最简单且推荐。
  • 使用。此方法有多个步骤,如果您有特定要求,例如不允许光栅支持,则此方法非常有用
  • 使用数据库。这对于设置具有类似功能的多个数据库非常有用。有时
    template\u postgis
    是预安装的,其他时候则需要创建该模板

  • 为什么您需要经历创建
    'template\u postgis'
    的繁琐步骤?只需创建一个新数据库并执行
    createextensionpostgis应该可以。我对PostgreSQL不太熟悉。我的印象是,创建模板是一种好形式,正确与否?在“创建扩展”成为可能之前,它是必需的。现在“创建扩展”被认为是最佳实践。是的,
    template\u postgis
    可以作为历史遗留物被遗忘。谢天谢地,谢谢你们。当键盘和椅子之间出现问题时,这总是一种解脱。
    createextensionpostgis不在数据库中创建相应的表!OSX Mavericks、Rails 4.1.1、Ruby 2.1.1、PostgreSQL 9.3.4、PostGIS 2.1.3
    select PostGIS_full_version()
    ST.*
    查询不返回函数匹配项。。超级烦人我发现了我的问题:在config/database.yml中有一个行模式\u search\u path:public.postgis,这导致无法生成地理表