PostgreSQL, pg_dump and pg_restore and object dependency order
Asked Answered
K

0

7

Is there any way to force PostgreSQL 9.3 backup / restore schema in the correct sequence of dependent objects?

Example

I need to create a function that is used in the materialized views before creating the materialized views itself.

I got an error in schema restoring, because the materialized view is created before creating function itself.

Kuster answered 8/6, 2015 at 11:6 Comment(3)
Before the dumping pg_dump does a topological sort of the objects, based on their dependancies, and attempts to dump based on this order. This will cause a warning during the dump if any cyclic dependancies are detected . In your case you should probably apply the create function parts manually after the resore itself. (pg_dump --schema only will give only the ddl, can be used to extract the function definitions, and/or materialised view definitions)Freemanfreemartin
@Freemanfreemartin Do you happen to know if there is any tool that is able to resolve dependency cycles (e.g. if we have Book.author and Author.first_book where first_book is nullable, you could first insert the author with first_book=Null and add an update later)Triturate
why are you asking a question as a comment to another comment from 9 years ago @Martin Thoma? Post a new questionDrugge

© 2022 - 2024 — McMap. All rights reserved.