Skip to content

Conversation

@tianzhou
Copy link
Contributor

@tianzhou tianzhou commented Nov 7, 2025

Fix #148

Copilot AI review requested due to automatic review settings November 7, 2025 18:07
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 fixes a dependency ordering issue in SQL migration generation by ensuring triggers are dropped before their associated functions when functions are being replaced or removed. This prevents PostgreSQL errors where a function cannot be dropped while triggers still reference it.

Key changes:

  • Added generateDropTriggersFromModifiedTables function to collect and drop triggers from modified tables before functions are dropped
  • Integrated this function into the generateDropSQL workflow to enforce proper dependency ordering
  • Updated test data to reflect the corrected drop order

Reviewed Changes

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

Show a summary per file
File Description
internal/diff/trigger.go Added new function to handle dropping triggers from modified tables with proper ordering
internal/diff/diff.go Integrated trigger drop function into the drop SQL generation workflow
testdata/diff/dependency/function_to_trigger/*.sql Updated test data to reflect correct drop order (trigger first, then function)
testdata/diff/dependency/function_to_trigger/*.txt Updated plan output showing correct execution order
testdata/diff/dependency/function_to_trigger/*.json Updated JSON plan with proper step ordering

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

@tianzhou tianzhou force-pushed the function_trigger_dependency branch from 5e5a978 to 6c6c5e2 Compare November 7, 2025 18:10
@tianzhou tianzhou requested a review from Copilot November 7, 2025 18:11
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

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


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

@tianzhou tianzhou force-pushed the function_trigger_dependency branch from 6c6c5e2 to e2a43ee Compare November 7, 2025 18:22
@tianzhou tianzhou requested a review from Copilot November 7, 2025 18:22
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

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


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

@tianzhou tianzhou merged commit 52e5470 into main Nov 7, 2025
8 checks passed
@tianzhou tianzhou deleted the function_trigger_dependency branch November 23, 2025 14:51
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.

Can't drop trigger function

1 participant