Pg_dump custom data type

I am migrating select tables from my server to my laptop to work on my local machine. Dropping the entire db is not allowed due to the lack of space on my laptop. One of the columns in the same table is a custom datatype and when restoring, I get the following error:

pg_restore: [archiver (db)] could not execute query: ERROR: type "custom_data_type" does not exist

There are two ways to solve this problem, but I am having a hard time finding instructions online:

  • Make sure the datatypes the table depends on are included in `pg_dump
  • Find the generated script for the custom data type
+3


source to share


1 answer


pg_dump

has the ability to:

-s --schema only

Dump only object definitions (schema), not data.

This parameter is the inverse of --data-only. It is similar, but not identical for historical reasons, by specifying --section = pre-data --section = post-data.

(Do not confuse this with the --schema option, which uses the word "schema" in a different sense.)



What if your source database doesn't have a ton of DDL, you should be fine. If your source has a ton of DDL, you can manually extract the creation of the script type from the output pg_dump

using your chosen text editor.

+3


source







All Articles