Skip to content

Design question: Single-pass convergence vs eventual convergence? #240

@asonawalla

Description

@asonawalla

I ran into a behavior that got me curious about the project's design intent.

When adding a new column with a COMMENT ON COLUMN, it takes two plan/apply cycles to converge - the first plan/apply creates the column, the second adds the comment. The comment doesn't appear in the first plan even though it's in the schema file.

This made me wonder: is pgschema designed to be single-pass (like Terraform) or eventual-convergence? Looking at the code, there's clearly effort toward correct ordering - topological sorting for tables/views/types, deferred foreign keys, pre-dropping dependent materialized views. So single-pass seems like the intent, but I couldn't find it stated anywhere.

If single-pass is the goal, the current approach handles it through a mix of hardcoded phase ordering, topological sort within phases, and individual special cases as they're discovered. A dependency graph approach (each operation declares what must exist first) could handle this uniformly and guarantee single-pass by construction - but that's a bigger architectural shift.

Would be very happy to brainstorm some approaches here. I'll submit a patch to fix the column comment case using the current patterns shortly.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions