Re: pg_restore failed for foreign key constraint

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Neha Sharma <neha(dot)sharma(at)enterprisedb(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_restore failed for foreign key constraint
Date: 2017-07-17 14:03:33
Message-ID: 21358.1500300213@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Neha Sharma <neha(dot)sharma(at)enterprisedb(dot)com> writes:
> I am getting the below error while restoring data having foreign key
> constraint.

> [edb(at)localhost bin]$ ./createdb test1
> [edb(at)localhost bin]$ ./pg_restore -d test1 -c -e a.dump
> pg_restore: [archiver (db)] Error while PROCESSING TOC:
> pg_restore: [archiver (db)] Error from TOC entry 2903; 2606 16399 FK
> CONSTRAINT test_tbl test_tbl_fk_c1 edb
> pg_restore: [archiver (db)] could not execute query: ERROR: schema "test"
> does not exist
> Command was: ALTER TABLE ONLY test.test_tbl DROP CONSTRAINT
> test_tbl_fk_c1;

> Is this an expected behaviour?

Yes, it is. Either don't use -c (it's entirely useless when restoring
into an empty database), or specify --if-exists, or ignore the errors.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2017-07-17 14:48:07 Unportable use of select for timeouts in PostgresNode.pm
Previous Message Shubham Barai 2017-07-17 13:38:25 Re: GSoC 2017: weekly progress reports (week 6)