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
Move SQL triggers from migrations into reusable sql file #4333
Conversation
Tests now pass, and I also made replaceable_schema code run in the same transaction as the last migration, so if it replaceable_schema doesn't successfully run, then it will be run again when the server is restarted, which would otherwise be prevented by the lack of pending migrations |
cc @phiresky |
In a future PR, I think I will add a custom implentation of migration commands (e.g. Edit: This will also make it possible to store the previously run code in a single-row table and use that instead of checking if any pending migrations were run to determine whether or not to run replaceable_schema again, since it will be guaranteed that the |
I'm good to have this go into |
Looks good as far as I can tell, but you need to resolve a conflict. |
|
This migration cannot be performed at my instance. When upgrading from 0.19.3 to 0.19.4 I get:
|
You've created multiple hot_rank functions then, you'll need to remove one of them. This would fail CI and upgrades on our dev machines if this migration was broken. I'll also test this locally with a production DB. |
@dessalines I am not really sure what you mean by I started with an empty database around version 0.17 and no command was ever executed against my database, except for the automatic migrations when upgrading to new releases. Except for one time that I was asked by @dullbananas to ran a query to gather performance statistics from the pg_stat table. But that query did not alter any schema's or functions. |
Lets move this discussion to the open ticket. |
Fix some aggregates fields being set in update triggers but not in insert triggers, which can be a problem when something is both created and updated before being sent to another instance (fixes [Bug]: Posts featured by a remote mod are not featured on host instance #3544)
Check if the post is removed or deleted in the comment trigger (previously only done in the post update trigger)
Remove handling of deletion that's already done by
ON DELETE CASCADE
in foreign keysUse published field instead of calling
now
again, which is more correct for federationNo more total recount of community_aggregates.comments
Optimize all triggers for bulk operations (except for the trigger that deletes a post's comments) (very important for the tool introduced in Better query plan viewing experience #4285)
End the painful era of trigger migrations
Here's the report triggers that used to be in this PR, in case they need to be added again in the future: