Class DepcyResolver

java.lang.Object
org.pgcodekeeper.core.model.graph.DepcyResolver

public final class DepcyResolver extends Object
Core dependency resolution engine that determines database object changes required for schema migration. Analyzes two database schemas and generates a complete set of CREATE, ALTER, and DROP actions while respecting object dependencies and handling complex dependency chains.

Implementation notes:

General idea behind this class is graph passes that collect required actions. addDropStatements starts a bottom-to-top pass in the old DB graph, addCreateStatements starts a top-to-bottom pass in the new DB graph. When these passes reach an object requiring an ALTER, an "opposite direction" pass for that object is started. This also allows us to treat alters as "drops" here. Passes are eventually exhausted when all the actions have been collected into actions set.

At the very end recreateDrops is called, which starts a "create pass" for every object that was dropped but should not have been - i.e. it was a dependency related drop. These passes are performed until they stop generating new actions. This ensures that all dropped dependencies have been recreated, and any dependency drops that may have been generated in the process have also been accounted for.