Skip to content

feat: always dump separate constraint with name#85

Merged
tianzhou merged 1 commit intomainfrom
explicit_constraint_name
Oct 15, 2025
Merged

feat: always dump separate constraint with name#85
tianzhou merged 1 commit intomainfrom
explicit_constraint_name

Conversation

@tianzhou
Copy link
Contributor

Fix #83

Copilot AI review requested due to automatic review settings October 15, 2025 11:26
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces always-named constraint mode for pgschema, fixing issue #83 where explicitly named constraints were being converted to inline syntax during dumping. The change ensures all constraints are dumped as table-level with explicit names, preserving constraint names and improving schema consistency.

Key changes:

  • Modified constraint generation to always use named table-level format (e.g., CONSTRAINT users_pkey PRIMARY KEY (id))
  • Updated both CREATE TABLE and ALTER TABLE statements to use consistent constraint naming
  • Added support for preserving complex foreign key attributes (DEFERRABLE, NOT VALID)

Reviewed Changes

Copilot reviewed 129 out of 129 changed files in this pull request and generated no comments.

Show a summary per file
File Description
internal/diff/table.go Refactored constraint handling to generate all constraints as table-level with explicit names
internal/diff/constraint.go Updated constraint SQL generation to always include constraint names
internal/diff/identifier_quote_test.go Updated test expectations to match new named constraint format
cmd/dump/dump_integration_test.go Added integration test for issue #83
testdata/dump/issue_83_explicit_constraint_name/* Added test case data for named constraint preservation
Multiple testdata files Updated expected outputs to reflect new constraint naming format

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@tianzhou tianzhou force-pushed the explicit_constraint_name branch from 60dfc68 to ae39c14 Compare October 15, 2025 11:32
@tianzhou tianzhou merged commit e207791 into main Oct 15, 2025
2 checks passed
@tianzhou tianzhou deleted the explicit_constraint_name branch October 23, 2025 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Named foreign key constraints do not retain their name when dumped

2 participants