Add --branch flag for reusing existing PlanetScale branches#35
Draft
aparajon wants to merge 7 commits intoarmand/progress-template-keyspacefrom
Draft
Add --branch flag for reusing existing PlanetScale branches#35aparajon wants to merge 7 commits intoarmand/progress-template-keyspacefrom
aparajon wants to merge 7 commits intoarmand/progress-template-keyspacefrom
Conversation
e720542 to
856ac5f
Compare
There was a problem hiding this comment.
Pull request overview
Adds support for reusing an existing PlanetScale branch during schemabot apply by introducing a --branch <name> option that attempts to sync that branch with main before continuing the normal apply flow (to avoid the branch-creation wait).
Changes:
- Add
--branchflag to the CLI apply command and plumb it through the apply API options. - Extend the PlanetScale engine apply flow to reuse/sync an existing branch when requested.
- Extend the PlanetScale client interface with
SyncBranch(raw HTTP) andDeleteBranch.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/psclient/client.go | Adds DeleteBranch and raw-HTTP SyncBranch to the PS client wrapper/interface. |
| pkg/engine/planetscale/planetscale.go | Updates Apply() to reuse/sync an existing branch when options["branch"] is set. |
| pkg/cmd/commands/rollback.go | Updates call site for applyAndWatch signature change. |
| pkg/cmd/commands/common.go | Adds branch parameter and forwards it as options["branch"] to the apply API. |
| pkg/cmd/commands/apply.go | Adds --branch flag and validates it’s only used with Vitess/PlanetScale engines. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
856ac5f to
9ea3eb0
Compare
b2daa02 to
f72710d
Compare
Adds branch reuse support to skip the ~60s (or ~10min for 30+ keyspaces) branch creation phase. When --branch is specified, the engine syncs the existing branch with main instead of creating a new one. CLI: --branch flag on apply command, validated as Vitess-only. Engine: checks for options["branch"], calls SyncBranch API instead of CreateBranch, waits for sync to complete, then proceeds with DDL. PSClient: added SyncBranch (raw HTTP, not in Go SDK) and DeleteBranch. Also fixes skip_revert not being passed through the apply options map. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Implements branch sync for LocalScale: drops existing branch databases, re-snapshots schema from main via vtgate, and marks the branch ready. This is the LocalScale equivalent of PlanetScale's branch sync API. Integration tests verify: - TestSyncBranch: sync removes branch-only schema changes - TestSyncBranchAndApply: full branch reuse workflow with two consecutive deploys on the same branch Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Default baseURL for SyncBranch so it works with NewPSClient - Include response body in SyncBranch HTTP errors - Reject --branch main to prevent applying DDL to the main branch - Disable auto-delete when reusing a branch so it survives for reuse Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Reject --branch main early in the CLI before sending to the server. The engine already rejects it server-side, but client-side gives faster feedback. Both checks protect against applying DDL directly to the main branch. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ShardProgress adds an INDEX to a 2-shard table. In -o log mode, the CLI blocks for the full lifecycle which exceeds the 30s CLI timeout on slow CI runners. Use --no-watch so the CLI exits immediately, then poll for shard progress during the running state when the engine is live and SHOW VITESS_MIGRATIONS has shard data. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
TestVitess_Apply_BranchReuse creates a branch via LocalScale API, then runs two consecutive applies using --branch flag through the full CLI → server → engine path. Verifies branch sync, apply completion, and branch survival for reuse. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
53a35df to
cc88a68
Compare
2f2150f to
9dd258f
Compare
The PlanetScale API uses /refresh-schema (not /sync) to update a branch's schema from main. Use the SDK's RefreshSchema method instead of raw HTTP. Rename throughout: SyncBranch → RefreshSchema, event messages show "Refreshing branch schema" instead of "Syncing branch". Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
9dd258f to
3fc419b
Compare
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.
Adds
--branchflag toschemabot applyfor reusing an existing PlanetScale branch instead of creating a new one. This skips the 60s+ branch creation wait by syncing an existing branch with main.--branch <name>verifies the branch exists and is ready, syncs it with main via the PlanetScale API, waits for sync to complete, then continues with the normal DDL apply flowSyncBranchto the PS client (raw HTTP — not in the Go SDK)DeleteBranchto the PS client interface🤖 Generated with Claude Code