Feature Request
Description:
Provide lifecycle hooks (before_refresh, after_refresh) that can be configured to run before and after a materialized view is refreshed.
Use Case:
This allows developers to inject custom logic into the refresh process, such as logging to an audit trail, busting external caches, or triggering other downstream processes.
Proposed Solution:
- In the initializer, allow configuration of global
before_refresh and after_refresh lambdas that receive the view definition as an argument.
- Allow these to be defined on a per-view basis as well, perhaps as serialized attributes on the model.
- The
MatViewRefreshJob will execute these hooks at the appropriate times.
RSpec Tests:
- Configure a
before_refresh hook that sets a flag.
- Run a refresh and verify the flag was set before the refresh SQL was executed.
- Configure an
after_refresh hook.
- Run a successful refresh and a failed refresh, and verify the hook is called in both cases with the correct status.
Checklist:
Feature Request
Description:
Provide lifecycle hooks (
before_refresh,after_refresh) that can be configured to run before and after a materialized view is refreshed.Use Case:
This allows developers to inject custom logic into the refresh process, such as logging to an audit trail, busting external caches, or triggering other downstream processes.
Proposed Solution:
before_refreshandafter_refreshlambdas that receive the view definition as an argument.MatViewRefreshJobwill execute these hooks at the appropriate times.RSpec Tests:
before_refreshhook that sets a flag.after_refreshhook.Checklist: