Skip to content

feat(pg): add metadata schema diff migration#20098

Merged
rebelice merged 4 commits into
mainfrom
codex/pg-metadata-schema-diff
Apr 23, 2026
Merged

feat(pg): add metadata schema diff migration#20098
rebelice merged 4 commits into
mainfrom
codex/pg-metadata-schema-diff

Conversation

@rebelice

Copy link
Copy Markdown
Contributor

Summary

  • Route PostgreSQL/CockroachDB metadata-backed schema diff through a new object-level metadata migration generator instead of SDL text round-tripping.
  • Generate PG metadata migration SQL for tables, indexes, FKs, views, materialized views, routines, enums, sequences, schemas, extensions, event triggers, and comments.
  • Limit destructive drop blast radius by avoiding schema CASCADE, skipping public/pg_catalog schema drops, and dropping cyclic table FKs before table drops.

Test Plan

  • go test -count=1 ./backend/plugin/schema/pg
  • go test -count=1 ./backend/plugin/schema
  • go test -count=1 ./backend/api/v1 -run '^(TestShouldDiffSchemaViaSDL)$'
  • golangci-lint run --allow-parallel-runners
  • go build -ldflags "-w -s" -p=16 -o ./bytebase-build/bytebase ./backend/bin/server/main.go

Notes

  • No breaking change label: this keeps API/proto/schema shapes unchanged and fixes PG/Cockroach metadata diff behavior.
  • Composite-PK checklist skipped: this PR does not touch backend/store or migrator queries.

@rebelice rebelice requested a review from a team as a code owner April 23, 2026 06:26
@cla-bot cla-bot Bot added the cla-signed label Apr 23, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 64585503b8

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread backend/plugin/schema/pg/metadata_migration.go
Comment thread backend/plugin/schema/pg/metadata_migration.go
Comment thread backend/plugin/schema/pg/metadata_migration.go

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b14254ab29

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread backend/plugin/schema/pg/metadata_migration.go
Comment thread backend/plugin/schema/pg/metadata_migration.go

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2b612aa707

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread backend/plugin/schema/pg/metadata_migration.go Outdated
Comment thread backend/plugin/schema/pg/metadata_migration.go Outdated
@sonarqubecloud

Copy link
Copy Markdown

@rebelice rebelice merged commit 596acb6 into main Apr 23, 2026
16 checks passed
@rebelice rebelice deleted the codex/pg-metadata-schema-diff branch April 23, 2026 07:45
@github-actions

Copy link
Copy Markdown

Successfully created backport PR for release/3.17.1:

rebelice added a commit that referenced this pull request Apr 23, 2026
* feat(pg): add metadata schema diff migration

* fix(pg): handle metadata diff dependency edge cases

* fix(pg): handle metadata diff dependent objects

* fix(pg): order metadata diff table dependencies

(cherry picked from commit 596acb6)

Co-authored-by: rebelice <yangrebelice@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants