pg_aqueduct Migration Cookbook

30 worked examples covering the most common stream-table evolution patterns. Every example is verified end-to-end against a Testcontainers PostgreSQL cluster (see crates/aqueduct-core/tests/integration.rs, test_cookbook_* functions).

Pattern Categories

Free class — metadata-only changes (no rebuild, no data movement)

#PatternTest
01Change schedule to a faster intervaltest_cookbook_01_change_schedule_faster
02Change schedule to a slower intervaltest_cookbook_02_change_schedule_slower
03Enable CDC mode (WAL replication)test_cookbook_03_enable_cdc_mode
04Switch refresh mode DIFFERENTIAL → FULLtest_cookbook_04_diff_to_full_refresh

In-place class — additive changes; materialised state preserved

#PatternTest
05Add a SUM aggregate columntest_cookbook_05_add_sum_aggregate_column
06Add a COUNT(*) columntest_cookbook_06_add_count_column
07Drop a column from the SELECT listtest_cookbook_07_drop_aggregate_column
08Add an aggregate column without changing GROUP BYtest_cookbook_08_add_passthrough_column
09Extend the SELECT list with a new aggregatetest_cookbook_09_widen_column_type

Rebuild class — structural changes; full DROP + recreate + backfill

#PatternTest
10Rename a columntest_cookbook_10_rename_column_is_rebuild
11Change GROUP BY keystest_cookbook_11_change_group_by_is_rebuild
12Add a JOINtest_cookbook_12_add_join_is_rebuild
13Remove a JOINtest_cookbook_13_remove_join_is_rebuild
14Change a JOIN conditiontest_cookbook_14_change_join_condition_is_rebuild
15Add a WHERE predicatetest_cookbook_15_add_where_predicate_is_rebuild
16Change a WHERE predicatetest_cookbook_16_change_where_predicate_is_rebuild
17Switch refresh mode FULL → DIFFERENTIALtest_cookbook_17_full_to_diff_is_rebuild

Create / Drop

#PatternTest
18Create a new stream tabletest_cookbook_18_create_stream_table
19Drop an existing stream tabletest_cookbook_19_drop_stream_table

DAG topology patterns

#PatternTest
20Two-node dependency DAG (A → B)test_cookbook_20_two_node_dag
21Add a downstream dependent nodetest_cookbook_21_add_downstream_node
22Remove a downstream nodetest_cookbook_22_remove_downstream_node
23Three-level dependency chaintest_cookbook_23_three_level_chain

Consumer views

#PatternTest
24Create a consumer viewtest_cookbook_24_create_consumer_view
25Drop a consumer viewtest_cookbook_25_drop_consumer_view

Multi-table and advanced patterns

#PatternTest
26Source column change cascades to stream tablestest_cookbook_26_source_column_cascade
27Change schedule on multiple tables simultaneouslytest_cookbook_27_multi_table_schedule_change
28Import from live — idempotent round-triptest_cookbook_28_import_roundtrip
29Rollback across version boundariestest_cookbook_29_rollback_to_prior_state
30Full lifecycle: create → evolve → destroytest_cookbook_30_full_dag_lifecycle

Classification Quick Reference

Change type                             Migration class   Cost
──────────────────────────────────────────────────────────────
Schedule change                         Free              < 1s
cdc_mode change                         Free              < 1s
refresh_mode DIFF → FULL               Free              < 1s
Add aggregate column (no GROUP BY Δ)   In-place          seconds
Drop column from SELECT                 In-place          seconds
Rename column                           Rebuild           minutes
Change GROUP BY keys                    Rebuild           minutes
Add / remove / change JOIN              Rebuild           minutes
Add / change WHERE predicate           Rebuild           minutes
refresh_mode FULL → DIFF               Rebuild           minutes
Create new stream table                 Create            seconds–minutes
Drop stream table                       Drop              < 1s
Blue/green structural DAG change        Blue/green        background