Skip to content

Plan, progress, and TUI improvements for planetscale#37

Open
aparajon wants to merge 5 commits intomainfrom
armand/progress-template-keyspace
Open

Plan, progress, and TUI improvements for planetscale#37
aparajon wants to merge 5 commits intomainfrom
armand/progress-template-keyspace

Conversation

@aparajon
Copy link
Copy Markdown
Collaborator

@aparajon aparajon commented Apr 24, 2026

  • Parallel plan — schema fetching and diffing now run with up to 20 concurrent goroutines per keyspace, reducing plan time for 30+ keyspace databases from serial to ~2s
  • Collapse identical keyspaces — when 6+ consecutive keyspaces have the same DDL changes, plan output shows the first 3 headers then "... and N more keyspaces with identical changes" with the DDL printed once
  • Schema API routing — plan uses PlanetScale schema API when safe_migrations is enabled on the branch, vtgate when disabled. Removed the api-plan fake environment hack
  • Keyspace progress — namespace preserved through engine progress, local task sync, and terminal rendering so duplicate table names across keyspaces show correct headers
  • TUI error display — failed applies now show the error message in red with recovery guidance instead of silent ❌ Failed
  • LocalScale deploy scoping — deploy request allocation, lookup, updates, and processor transitions scoped by org/database/number

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings April 24, 2026 19:05
Copy link
Copy Markdown

Copilot AI left a 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 fixes PlanetScale planning accuracy by selecting the correct “current schema” source based on whether safe schema changes are enabled, and it makes progress reporting keyspace-aware so duplicate table names across Vitess keyspaces are tracked and rendered correctly.

Changes:

  • Choose PlanetScale plan “current schema” source based on branch safe-migrations mode (API when enabled, vtgate when disabled).
  • Preserve and use namespace/keyspace in engine progress → task syncing → UI/API rendering to avoid collisions on duplicate table names.
  • Add LocalScale safe_migrations config and Docker-backed integration tests covering both schema-source paths.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/tern/progress_keys.go Adds shared (tern-local) namespace/table keying helpers for progress lookup.
pkg/tern/progress_keys_test.go Unit tests ensuring namespace-aware progress matching and fallback behavior.
pkg/tern/local_control.go Uses namespace-aware progress matching when snapshotting and applying engine progress to tasks.
pkg/tern/local_client.go Uses namespace-aware engine progress mapping for terminal progress rendering and task selection tweaks.
pkg/tern/local_apply.go Uses namespace-aware per-table progress when syncing atomic tasks from engine results.
pkg/localscale/testcontainer.go Extends container DB config to allow toggling safe_migrations.
pkg/localscale/server_integration_test.go Adds databases/keyspaces to test safe-migrations enabled/disabled behavior in containerized LocalScale.
pkg/localscale/server.go Plumbs SafeMigrations config through to backend state with a default of true.
pkg/localscale/handlers_branches.go Returns correct safe_migrations value in branch responses (including virtual main).
pkg/localscale/planetscale_engine_integration_test.go Integration test validating plan schema source selection (API vs vtgate) and error behavior without DSN.
pkg/engine/engine.go Adds Namespace field to engine.TableProgress for keyspace-aware progress.
pkg/engine/planetscale/planetscale.go Adds schema-source selection logic and vtgate schema fetch implementation; includes namespace in aggregated progress.
pkg/api/progress_handlers.go Makes API progress/task correlation namespace-aware and preserves keyspace in responses.
pkg/api/progress_handlers_test.go Tests keyspace preservation for terminal applies and namespace-aware sync from Tern progress.
cmd/localscale/main.go Adds safe_migrations to LocalScale config parsing and wiring.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/engine/planetscale/planetscale.go Outdated
@aparajon aparajon force-pushed the armand/progress-template-keyspace branch 2 times, most recently from 4e09f24 to 6342993 Compare April 24, 2026 20:31
@aparajon aparajon force-pushed the armand/progress-template-keyspace branch from 6342993 to a9c1575 Compare April 24, 2026 20:39
@aparajon aparajon marked this pull request as ready for review April 24, 2026 21:02
@aparajon aparajon requested a review from morgo as a code owner April 24, 2026 21:02
@aparajon aparajon changed the title Fix PlanetScale plan schema source Fix Vitess planning, keyspace progress, and LocalScale deploy scoping Apr 24, 2026
@aparajon aparajon changed the title Fix Vitess planning, keyspace progress, and LocalScale deploy scoping Fix planetscale engine planning, keyspace progress, and LocalScale deploy scoping Apr 24, 2026
aparajon and others added 3 commits April 24, 2026 19:16
The TUI's footer switch had no case for the failed state, so apply
errors from the progress API were never displayed. Now shows the
error in red with recovery guidance when the apply reaches failed state.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The engine already checks SafeMigrations from the PlanetScale branch
response to decide whether to use the schema API or vtgate for plan.
The api-plan environment with a broken DSN was a workaround to force
the API path. Since LocalScale defaults safe_migrations to true, the
staging environment already uses the schema API path.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Schema fetching and Spirit PlanChanges diffing now run with up to 20
concurrent goroutines per keyspace. For databases with 30+ keyspaces
this reduces plan time from sequential (30+ serial API calls) to
parallel (~2s).

Results are collected in deterministic keyspace order.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@aparajon aparajon force-pushed the armand/progress-template-keyspace branch from be2e14a to d20b978 Compare April 24, 2026 23:34
@aparajon aparajon changed the title Fix planetscale engine planning, keyspace progress, and LocalScale deploy scoping Parallel plan, keyspace progress, schema API routing, and TUI error display Apr 24, 2026
@aparajon aparajon changed the title Parallel plan, keyspace progress, schema API routing, and TUI error display planetscale fixes: Parallel plan, keyspace progress, schema API routing, and TUI error display Apr 24, 2026
@aparajon aparajon changed the title planetscale fixes: Parallel plan, keyspace progress, schema API routing, and TUI error display planetscale fixes: parallel plan, keyspace progress, schema API routing, and TUI error display Apr 24, 2026
@aparajon aparajon changed the title planetscale fixes: parallel plan, keyspace progress, schema API routing, and TUI error display Add parallelization to plan, update keyspace progress, add schema API routing, and fix TUI error display Apr 24, 2026
When 6+ consecutive keyspaces have identical DDL changes, show the
first 3 keyspace headers then "... and N more keyspaces with identical
changes" followed by the DDL once. Common pattern for sharded databases
with numbered keyspaces sharing the same schema.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@aparajon aparajon force-pushed the armand/progress-template-keyspace branch from ed06699 to 3d1216c Compare April 24, 2026 23:43
@aparajon aparajon changed the title Add parallelization to plan, update keyspace progress, add schema API routing, and fix TUI error display Plan, progress, and TUI improvements for planetscale Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants