Skip to content

(reversible) rename_constraint helper#38

Merged
ccutrer merged 2 commits into
instructure:mainfrom
ccutrer:rename_constraint
Jul 16, 2026
Merged

(reversible) rename_constraint helper#38
ccutrer merged 2 commits into
instructure:mainfrom
ccutrer:rename_constraint

Conversation

@ccutrer

@ccutrer ccutrer commented Jul 16, 2026

Copy link
Copy Markdown
Member

also add constraint_exists?

also add constraint_exists?
@ccutrer
ccutrer requested a review from Copilot July 16, 2026 15:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a new rename_constraint migration/helper for PostgreSQL (with optional if_exists: behavior) and makes it reversible through ActiveRecord’s CommandRecorder, integrating the recorder via the gem’s Railtie.

Changes:

  • Add PostgreSQLAdapter#rename_constraint that emits ALTER TABLE ... RENAME CONSTRAINT ....
  • Add constraint_exists? helper used to implement if_exists: behavior.
  • Add ActiveRecord::PGExtensions::CommandRecorder support and wire it into Rails initialization; add specs for the new behavior.

Reviewed changes

Copilot reviewed 5 out of 8 changed files in this pull request and generated 1 comment.

File Description
spec/postgresql_adapter_spec.rb Adds specs for SQL emitted by rename_constraint, if_exists: behavior (stubbed), and reversibility via CommandRecorder.
lib/active_record/pg_extensions/railtie.rb Loads the new command recorder extension and includes it into ActiveRecord::Migration::CommandRecorder.
lib/active_record/pg_extensions/postgresql_adapter.rb Introduces rename_constraint and constraint_exists? used to support if_exists:.
lib/active_record/pg_extensions/command_recorder.rb Adds recording + inversion logic so rename_constraint is reversible in migrations.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/active_record/pg_extensions/postgresql_adapter.rb
@ccutrer
ccutrer requested review from maths22 and rmsy July 16, 2026 17:42
@ccutrer
ccutrer merged commit b8c80b0 into instructure:main Jul 16, 2026
10 checks passed
@ccutrer
ccutrer deleted the rename_constraint branch July 16, 2026 18:01
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.

3 participants