Jonathan Scott <jwscott@vanten.com> writes:
> The functions and tables create just fine, but when it gets to the
> COPY part of the sql script, it tries to load tables in what really is
> the wrong order. The check constraint is making sure there is a "plan"
> before there is a "contract", yet pg_dump is trying to load the
> contract table before there is anything in the plan table.
Shouldn't you be using a foreign key for that?
I don't see any reasonable way that pg_dump can be expected to
understand that a check constraint expresses a relationship between two
tables. The semantics of check constraints aren't right for it anyway.
All else being equal, I think the tables will be loaded in OID order,
so a possible workaround is to create the plan table first. But an
FK seems like a better answer.
regards, tom lane