如何使用 AWS DMS 迁移具有默认值、约束和序列的表以进行 postgres 到 postgres 迁移?

Sud*_*hra 6 postgresql amazon-web-services amazon-rds

我最近从 RDS postgresql 迁移到 Aurora postgresql。表已成功迁移,但表缺少默认值、约束和引用。它也没有迁移任何序列。

源数据库中的表:

                                        Table "public.addons_snack"
    Column     |           Type           | Collation | Nullable |                 Default
---------------+--------------------------+-----------+----------+------------------------------------------
 id            | integer                  |           | not null | nextval('addons_snack_id_seq'::regclass)
 name          | character varying(100)   |           | not null |
 snack_type    | character varying(2)     |           | not null |
 price         | integer                  |           | not null |
 created       | timestamp with time zone |           | not null |
 modified      | timestamp with time zone |           | not null |
 date          | date                     |           |          |
Indexes:
    "addons_snack_pkey" PRIMARY KEY, btree (id)
Check constraints:
    "addons_snack_price_check" CHECK (price >= 0)
Referenced by:
    TABLE "addons_snackreservation" CONSTRAINT "addons_snackreservation_snack_id_373507cf_fk_addons_snack_id" FOREIGN KEY (snack_id) REFERENCES addons_snack(id) DEFERRABLE INITIALLY DEFERRED
Run Code Online (Sandbox Code Playgroud)

目标数据库中的表

                         Table "public.addons_snack"
    Column     |            Type             | Collation | Nullable | Default
---------------+-----------------------------+-----------+----------+---------
 id            | integer                     |           | not null |
 name          | character varying(100)      |           | not null |
 snack_type    | character varying(2)        |           | not null |
 price         | integer                     |           | not null |
 created       | timestamp(6) with time zone |           | not null |
 modified      | timestamp(6) with time zone |           | not null |
 date          | date                        |           |          |
Indexes:
    "addons_snack_pkey" PRIMARY KEY, btree (id)
Run Code Online (Sandbox Code Playgroud)

是我做错了什么还是 DMS 无法执行此操作?

sin*_*ang 1

这个SQL 片段将为您提供明确的答案。

您可以使用pg_dump和恢复索引和约束pg_restore,该代码片段包括执行它们。