feat: added support for index and trigger migration #3708
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
added support for trigger and index migration during snapshot and polling to periodically fetch trigger and index updates.
Implementation Details:
a. During initial migration (snapshot), the triggers and function will be fetched from source pg table and applied to dest table.
b. There will be periodically scan of triggers on src at interval of 1 min and the updated triggers will be applied to destination table.
Triggers are created disabled on the destination to prevent double execution. If a source trigger increments a counter on UPDATE, the change replicates to the destination. If the destination trigger is enabled, it runs again and increments the counter twice, causing incorrect values. Since data changes come from replication, not local operations, enabling triggers would duplicate side effects. Keeping them disabled ensures the destination matches the source without extra trigger logic. Enable them only if the destination needs its own separate trigger behavior.
The plan is to make polling of trigger and index make it configurable through UI.
Polling was choosen as updating trigger and index with some delay will not break any think (as data is already written immediately so updating trigger with delay doesn't impact.)