模式导入失败,“类型”ltree“不存在”

时间:2018-05-24 21:00:00

标签: postgresql amazon-rds

尝试将模式从Postgres 9.4导入Postgres RDS 9.6时出现以下错误:

ERROR:  type "ltree" does not exist
LINE 8:     path ltree,
                 ^

ltree安装在源:

ltree   | 1.0     | pg_catalog | data type for hierarchical tree-like structures

ltree安装在目的地:

ltree   | 1.1     | public     | data type for hierarchical tree-like structures

从Postgres转储:

pg_dump -h db0 -U deployer staging --schema public --schema-only > schema.dump

要恢复到RDS:

psql -h staging.us-east-1.rds.amazonaws.com -U deployer -d staging < schema.dump

架构转储中出现ltree的唯一位置是此语句:

CREATE TABLE public.table (
    id integer NOT NULL,
    customer_id integer DEFAULT 0,
    ordinal integer NOT NULL,
    root_id integer,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    path ltree,
    premium boolean DEFAULT false
);

转储中没有CREATE EXTENSION。我在尝试导入之前尝试添加它,但它无法解决问题。

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

如果deployer(您使用的用户&#34;导入&#34;转储)是rds_superuser您应该能够这样做,如果没有,您会看到:

ERROR:  permission denied to create extension "ltree"
HINT:  Must be superuser to create this extension.

例如:

mon=> set role stan;
SET
mon=> create extension ltree;
ERROR:  permission denied to create extension "ltree"
HINT:  Must be superuser to create this extension.
mon=> reset role;
RESET
mon=> create extension ltree;
CREATE EXTENSION
mon=> select session_user;
 session_user
--------------
 rdsadm
(1 row)

mon=> \du rdsadm
                           List of roles
  Role name  |          Attributes           |      Member of
-------------+-------------------------------+----------------------
 rdsadm      | Create role, Create DB       +| {rds_superuser,stan}
             | Password valid until infinity |