恢复PostgreSQL数据库时如何解决扩展问题

How to solve extensions issues when restore PostgreSQL Database

我正在恢复我使用

创建的数据库上的 .sql Postgres 转储
CREATE DATABASE my_database;

稍后当我用

恢复数据库时
psql my_database < dump.sql

但是,我遇到了几个阻止我恢复数据的错误:

ERROR:  schema "pglogical" already exists
ALTER SCHEMA
CREATE EXTENSION
COMMENT
ERROR:  could not open extension control file "/usr/share/postgresql/11/extension/pglogical.control": No such file or directory
ERROR:  extension "pglogical" does not exist
ERROR:  could not open extension control file "/usr/share/postgresql/11/extension/postgis.control": No such file or directory
ERROR:  extension "postgis" does not exist
ERROR:  function "order_sorting_weight" already exists with same argument types
ERROR:  type "public.geometry[]" does not exist
LINE 7:     viewer_locations public.geometry(Point,4326)[]

多次举报如下:

ERROR:  relation "auth_permission_id_seq" already exists
ALTER TABLE
ALTER SEQUENCE
ERROR:  relation "auth_user" already exists
ALTER TABLE
ERROR:  relation "auth_user_groups" already exists
ALTER TABLE
ERROR:  relation "auth_user_groups_id_seq" already exists

我猜是数据库的每一列。

我该如何解决这个问题?

好的,我只是通过更改我一直使用的海报版本解决了这个问题,因为我安装了最新版本的 Postgres (11.1),我无法将 .sql 转储文件恢复到它,并且转储文件正在从版本为 9.5 的数据库服务器中转储。所以我只是卸载了整个 Postgresql 并安装了它的 9.5 版本。我在 plogical-docs 的帮助下设置了 pglogical 扩展,现在一切都如我所愿。