feat: Schema Migration Service#8
Open
NFUChen wants to merge 21 commits into
Open
Conversation
Covers pgschema CLI integration, git-based schema source config, MigrationService RPC design, and frontend Schema Diff View. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Define PlanMigration, ApplyMigration (streaming), and GetSchemaSourceStatus RPCs for the schema migration feature. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PlanMigration syncs git, runs pgschema plan, stores result. ApplyMigration streams progress and executes pgschema apply. GetSchemaSourceStatus returns schema_source config for a connection. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Shows schema diffs from git source, supports DDL preview, and gated apply with confirmation dialog (requires ddl permission). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Show migration panel when no object is selected and the connection has a schema_source configured. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ype handling and utility functions
…in MigrationPanel
|
@William-W-Chen is attempting to deploy a commit to the bytebase Team on Vercel. A member of the Team first needs to authorize it. |
Greptile SummaryThis PR adds schema migration support through pgschema and a git-backed schema source. The main changes are:
Confidence Score: 1/5This should be fixed before merging.
|
| Filename | Overview |
|---|---|
| server/lib/pgschema.ts | Adds pgschema parsing and CLI execution; parser contract, connection options, and password handling need fixes. |
| server/services/migration-service.ts | Adds migration RPC handlers; auth checks, path handling, and apply progress behavior need attention. |
| server/lib/git.ts | Adds git cache sync; cache validation and concurrent sync behavior need protection. |
| src/components/sql-editor/schema/MigrationPanel.tsx | Adds the migration UI; schema-source status is not used to gate the workflow. |
| Dockerfile | Adds pgschema and git to the image; build arch handling can fail without a target arch. |
Reviews (1): Last reviewed commit: "chore: remove outdated schema migration ..." | Re-trigger Greptile
…ies for target architectures
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add schema migration support powered by pgschema. Users can compare their live database schema against a git-hosted SQL file and apply DDL changes directly from the pgconsole UI.
What it does
pgschema planto diff the live database against the desired schema, and shows the DDL changes grouped by operation (create/alter/drop).pgschema apply --auto-approvewith streaming progress and error reporting.schema_sourceconfigured.Configuration
Add
schema_sourceto any connection inpgconsole.toml:Architecture
Backend
proto/migration.protoMigrationServicewith 3 RPCs:PlanMigration,ApplyMigration(server streaming),GetSchemaSourceStatusserver/services/migration-service.tsserver/lib/git.tsserver/lib/pgschema.tspgschema planandpgschema apply, with JSON output parserserver/lib/plan-store.tsserver/lib/config.tsSchemaSourceConfigtype and TOML parsingserver/connect.tsCode.Internaldetails)Frontend
src/components/sql-editor/schema/MigrationPanel.tsxderivePanelState) driving all renders viaswitch/casesrc/components/sql-editor/RightPanel.tsxsrc/hooks/useMigration.tsuseApplyMigrationchecks streaming results forstatus: 'failed'and throwsDocker
gitadded to runtime Alpine imagepgschemaclones schema repos at runtimepgschemabinary bundled frombin/pgconsoleuserpgschemaembeds PostgreSQL for planning;initdbrefuses to run as rootTARGETARCHbuild argKey design decisions
MigrationPanelderives a singlePanelStatediscriminated union from two independent mutations, then renders via exhaustiveswitch. Eliminates the class of bugs where render priority order silently breaks on refactor.status: 'failed'on pgschema errors (ConnectRPC streaming doesn't throw on application-level failures). The client hook checks the final result and throws souseMutationsurfaces errors correctly.planId, avoiding stale plan data and large payloads in React state.Frontend UI:



After Migration: