feat: support COMMENT ON for all schema objects#278
Open
dilame wants to merge 1 commit intostripe:mainfrom
Open
feat: support COMMENT ON for all schema objects#278dilame wants to merge 1 commit intostripe:mainfrom
dilame wants to merge 1 commit intostripe:mainfrom
Conversation
Plumb pg_description through the introspection path and emit `COMMENT ON <kind> <name> IS '...'` (or `IS NULL` to clear) whenever the description on a schema object is added, changed, or removed. Covered objects: schema, extension, table, column, enum/type, sequence, index, primary/unique constraint (via index), check constraint, foreign key, function, procedure, trigger, view, materialized view, policy. Acceptance coverage: internal/migration_acceptance_tests/comment_cases_test.go.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Plan and apply
COMMENT ON ... IS '...'(orIS NULLto clear) whenever a description is added, changed, or removed in the declarative schema.Covered: schema, extension, table, column, type/enum, sequence, index, primary/unique constraint, check constraint, foreign key, function, procedure, trigger, view, materialized view, policy.
Why
COMMENT ON ...is part of the declarative schema (notably for tools like PostGraphile that consume comments as smart-tags), but plans currently silently drop them, forcing manual application alongside every migration.How
internal/queries/queries.sql: extended each existingGet*query to fetchobj_description/col_description.internal/schema/schema.go: addedDescription stringto every commentable schema struct.pkg/diff/comment_sql_generator.go: shared helpers (commentDDLForAdd,commentDDLForAlter,commentTarget*).COMMENT ON ...afterCREATEand on description-only diffs (without recreating the underlying object — important for views, functions, procedures, etc.).internal/migration_acceptance_tests/comment_cases_test.go: 31 cases — CREATE-with-comment, add, change, and remove for each object kind.No new flags; comment diffing is always-on. The behavior of all pre-existing tests is unchanged (snapshot hashes were re-computed where the test fixtures expected an empty description on objects that PG itself comments by default — e.g. the
publicschema,pg_stat_statements,pg_trgm).