I'm trying to do a pg_restore
on some SQL files. Here's the command I used when I dumped from the other database:
pg_dump -f /home/mctools/public_html/cp/upload/manufacturers.sql \
-Fc -i -v -O -x -t manufacturers \
-h localhost -p 5432 -U aztools_tools aztools_dbuser
And here is the restore command:
pg_restore -d mctools_dbuser -Fc -c -i -O -x \
-h localhost -p 5432 -U mctools_user \
/home/mctools/public_html/cp/upload/manufacturers.sql
Here is the error I get:
pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 2165; 2606 27769168
CONSTRAINT manufacturers_pk aztools_tools
pg_restore: [archiver (db)] could not execute query: ERROR: cannot drop constraint
manufacturers_pk on table manufacturers
because other objects depend on it
DETAIL: constraint products_fk01 on table products depends on index manufacturers_pk
HINT: Use DROP ... CASCADE to drop the dependent objects too.
Command was: ALTER TABLE ONLY public.manufacturers DROP CONSTRAINT manufacturers_pk;
What do I need to do to fix this?
pg_dump
by dumping plain SQL instead of using the PostgreSQL custom format. If it looks fine, try to restore dumped database objects withpsql -f plain_dump.sql
. – Oliver F. Nov 29 '12 at 7:01-c
option inpg_restore
? Exactly that's whypg_restore
tries to drop the objects you dumped. – dezso Nov 29 '12 at 10:15