Feat: Add dynamic schema and index migration support for Postgres→Postgres CDC mirrors #3702
+570
−6
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.
This PR adds end‑to‑end support for propagating schema and index changes from Postgres sources to Postgres destinations during CDC, gated behind new dynamic configuration flags.
Added
PEERDB_POSTGRES_CDC_SCHEMA_MIGRATION_ENABLEDto control column-level schema migration (add/drop/alter) for Postgres CDC mirrors.Added
PEERDB_POSTGRES_CDC_SCHEMA_MIGRATION_INDEX_ENABLEDto control index-level migration (create/drop) for Postgres CDC mirrors.For column-level schema migration:
There was already the support to detect the column drop and type change but it was just getting logged.
For index-level migration:
Existing support was only present for primary key index and not the column level indexes.
On every relation record similar to column level changes, added logic to compare current schema indexes with previous schema indexes. If there is a diff then apply it to target and update previous schema to current.