Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete trigger and trigger function on add column operation rollback #35

Merged
merged 2 commits into from
Jul 20, 2023

Conversation

andrew-farries
Copy link
Collaborator

Support for up SQL in add column operations was added in #34

When such an add column operation runs, a trigger (and therefore a trigger function) is created to implement running up SQL on insertions to the old schema.

This PR ensures that the trigger and function are dropped when the migration is rolled back:

  • Extract two functions so that the rollback operations can name the function to be dropped.
  • Add necessary assertion functions to the common test infra.
  • Add an afterRollback hook to the existing test for up SQL.

@exekias
Copy link
Member

exekias commented Jul 19, 2023

It feels like trigger handling will require some common helpers so they can be used across the board

Base automatically changed from support-up-sql-on-insert-update to main July 20, 2023 05:37
Extract the `triggerFunctionName` function so that the `Rollback` method
can use it to delete the function.

Deleting the function with `CASCADE` deletes the trigger that invokes
the function too.
Ensure that the trigger function and trigger are removed when an add
column operation (that specifies `up` SQL) is removed.
@andrew-farries andrew-farries force-pushed the delete-trigger-on-add-col-rollback branch from de076f9 to f9e141f Compare July 20, 2023 05:44
@andrew-farries andrew-farries merged commit 4663091 into main Jul 20, 2023
@andrew-farries andrew-farries deleted the delete-trigger-on-add-col-rollback branch July 20, 2023 05:50
andrew-farries added a commit that referenced this pull request Jul 21, 2023
#35 ensured that the triggers
added to run `up` SQL are removed on `Rollback`, but the same needs to
happen on `Complete`.

This PR does that and extends the test to check for it.
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.

2 participants