Neha Sharma <neha.sharma@enterprisedb.com> writes:
> I am getting the below error while restoring data having foreign key
> constraint.
> [edb@localhost bin]$ ./createdb test1
> [edb@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