Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pg_dump a custom data type

I'm transferring select tables from my server to my laptop to work on locally. Dumping the entire db is infeasible due to space constraints on my laptop. One of the columns of one table is a custom data type, 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 I could solve this problem, but I'm having trouble finding instructions online to:

  1. Ensure that the datatypes on which a table depends are included in `pg_dump
  2. Find the create script for the custom data type
like image 721
raphael Avatar asked Apr 17 '15 19:04

raphael


1 Answers

pg_dump has the option:

-s --schema-only

Dump only the object definitions (schema), not data.

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

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

Which, unless your source database has a ton of DDL, should be OK for you. If your source does have a ton of DDL, you can manually extract the type creation script from the pg_dump output with your text editor of choice.

like image 123
Politank-Z Avatar answered Sep 25 '22 02:09

Politank-Z