-
Notifications
You must be signed in to change notification settings - Fork 42
[Postgres Target] Replicate schema drop #673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for replicating schema drop operations to Postgres targets. Previously, schema drops were ignored during replication. The changes introduce a SchemaDropped flag in the schema diff structure and ensure that when a schema is marked as dropped, a DROP SCHEMA IF EXISTS ... CASCADE query is generated and executed on the target.
Changes:
- Added
SchemaDroppedfield to theDiffstruct in the schema diff logic - Updated
ComputeSchemaDiffto detect when a schema is dropped and set the flag - Modified the Postgres adapter to generate DROP SCHEMA queries when SchemaDropped is true
- Added test coverage for schema drop handling in the DDL adapter tests
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| pkg/schemalog/schema_diff.go | Added SchemaDropped field to Diff struct, updated IsEmpty() check, and added logic in ComputeSchemaDiff to detect schema drops |
| pkg/wal/processor/postgres/postgres_wal_ddl_adapter.go | Refactored schemaLogToQueries to remove unconditional CREATE SCHEMA, added DROP SCHEMA generation when SchemaDropped is true |
| pkg/wal/processor/postgres/postgres_wal_ddl_adapter_test.go | Added test case for schema dropped scenario, updated all existing test cases to expect CREATE SCHEMA query |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Merging this branch will increase overall coverage
Coverage by fileChanged files (no unit tests)
Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code. Changed unit test files
|
Description
This PR updates the replication logic to flag the schema being dropped in the schema diff, and replicating it downstream to Postgres targets. Currently schema drops were ignored in the target.
Related Issue(s)
Type of Change
Testing