postgresql - 从 Postgres 9 迁移到 13 后无法创建 postgis 扩展
问题描述
我们正在将我们的主要生产数据库从 Postgres 9.2.4 迁移到 Postgres 13.2。我们对数据库进行了 pg_dump/pg_restore 到它的新服务器,发现总共有 6 个表(99 个)似乎没有到达新位置。在尝试转储单个表然后恢复它们时,我们遇到了以下错误:
[user@server ~]$ psql -U db_user db_name < /home/pmena/tmp/missing_table_1.dump
SET
SET
SET
SET
SET
SET
SET
SET
ERROR: type "geometry" is only a shell
LINE 2: locationlonlat geometry,
^
ERROR: relation "db_user.missing_table_1" does not exist
ERROR: relation "missing_table_1" does not exist
invalid command \.
ERROR: relation "missing_table_1" does not exist
ERROR: relation "missing_table_1" does not exist
ERROR: relation "missing_table_1" does not exist
ERROR: relation "missing_table_1" does not exist
ERROR: relation "missing_table_1" does not exist
ERROR: relation "missing_table_1" does not exist
搜索像这样的 Stack Overflow 文章指出缺少 postgis 扩展。然后我尝试删除并重新创建扩展,但偶然发现了另一个错误:
db_name=# drop extension postgis;
ERROR: extension "postgis" does not exist
db_name=# create extension postgis;
ERROR: relation "spatial_ref_sys" already exists
所以现在似乎 postgis 扩展的某些组件spatial_ref_sys
已经存在,阻止我按照建议创建扩展。再说一次,如果 spatial_ref_sys 已经存在而没有它,那么它们是提供geometry
类型的另一种方式吗?
这是我希望我不必问的问题:从 Postres 9 到 13 的跳跃是否过于雄心勃勃?我们已经在 Postgres 13 上投入了一个多月的时间,并且在尝试使用这个功能子集之前没有发现任何问题。
与往常一样,提前感谢您。
解决方案
删除数据库,在其中重新创建它,CREATE EXTENSION postgis;
然后恢复转储。从转储中恢复可能会出现错误spatial_ref_sys
,但这应该没问题。
推荐阅读
- reactjs - 如何缓存或防止大型试剂组件的重新渲染
- java - Java swing - 无法显示表格
- netbeans-8 - NetBeans - 在哪里可以找到 IDE 日志?
- java - 无法使用相同 java 版本的 avdmanager 和其他 SDK 工具
- c# - 如何使用 Visual Studio 2017 创建 React 应用程序(无 Visual Studio 代码)
- java - 将 ResponseStatus 解析为 Response
- jquery - 如何在 jquery、ajax 和 CI 中重置()文本区域
- .net - 我在 Azure 应用服务中托管的应用程序中的 cookie 路径“/”
- redis - evcache vs redis
- ios - CMMotionManager 回调的“startDeviceMotionUpdatesToQueue”时应用程序崩溃