Skip to content

Handling Unsupported Objects With Hooks

pgferry reports certain objects instead of guessing how to recreate them. Hooks are the normal way to finish that work.

Objects you should expect to handle yourself

Section titled “Objects you should expect to handle yourself”
  • views
  • materialized views
  • routines or procedures
  • source triggers
  • generated-column follow-up DDL
  • custom validation SQL
NeedHook phase
create extensions or helper functions before data loadbefore_data
run ANALYZE or post-load data cleanup before validation/constraintsafter_data
clean invalid child rows before foreign keysbefore_fk
recreate views, functions, or final validation queriesafter_all
  1. Run pgferry plan migration.toml --output-dir hooks.
  2. Use the generated hook skeletons as the starting point.
  3. Treat the generated files as sensitive if they include commented source SQL definitions from the source catalog.
  4. Keep application-specific SQL in hook files rather than scattering it through runbooks.
  5. Rehearse the exact hook set before the final cutover run.
CREATE OR REPLACE VIEW {{schema}}.active_customers AS
SELECT customer_id, email
FROM {{schema}}.customer
WHERE active = true;

Use this in an after_all hook because the view depends on the finished schema and post-load objects.