From c64b47bb746b2ab546bed8f289a9f78b8c65c7db Mon Sep 17 00:00:00 2001 From: Matthias Crauwels Date: Wed, 8 Jul 2026 14:19:22 +0200 Subject: [PATCH 1/2] Add --global-keyspace to branch vtctld move-tables create Exposes the vtctld MoveTables Create --global-keyspace option so that --sharded-auto-increment-handling=REPLACE can auto-create the backing sequence tables at switch-traffic --initialize-target-sequences time. Part of planetscale/issues#2032. Requires the GlobalKeyspace field from planetscale/planetscale-go#322. Co-Authored-By: Claude Fable 5 --- internal/cmd/branch/vtctld/move_tables.go | 3 +++ internal/cmd/branch/vtctld/move_tables_test.go | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/internal/cmd/branch/vtctld/move_tables.go b/internal/cmd/branch/vtctld/move_tables.go index 6de459c94..a851883f8 100644 --- a/internal/cmd/branch/vtctld/move_tables.go +++ b/internal/cmd/branch/vtctld/move_tables.go @@ -48,6 +48,7 @@ func MoveTablesCreateCmd(ch *cmdutil.Helper) *cobra.Command { deferSecondaryKeys bool onDDL string shardedAutoIncrementHandling string + globalKeyspace string sourceTimeZone string tenantID string cells []string @@ -84,6 +85,7 @@ func MoveTablesCreateCmd(ch *cmdutil.Helper) *cobra.Command { Tables: flags.tables, OnDDL: flags.onDDL, ShardedAutoIncrementHandling: flags.shardedAutoIncrementHandling, + GlobalKeyspace: flags.globalKeyspace, SourceTimeZone: flags.sourceTimeZone, TenantID: flags.tenantID, Cells: flags.cells, @@ -132,6 +134,7 @@ func MoveTablesCreateCmd(ch *cmdutil.Helper) *cobra.Command { cmd.Flags().BoolVar(&flags.deferSecondaryKeys, "defer-secondary-keys", true, "Defer secondary keys during the copy phase") cmd.Flags().StringVar(&flags.onDDL, "on-ddl", "", "DDL handling strategy (IGNORE, STOP, EXEC, EXEC_IGNORE)") cmd.Flags().StringVar(&flags.shardedAutoIncrementHandling, "sharded-auto-increment-handling", "", "Auto increment handling for sharded keyspaces") + cmd.Flags().StringVar(&flags.globalKeyspace, "global-keyspace", "", "Unsharded keyspace in which to create the backing sequence tables when --sharded-auto-increment-handling is REPLACE") cmd.Flags().StringVar(&flags.sourceTimeZone, "source-time-zone", "", "Source time zone") cmd.Flags().StringVar(&flags.tenantID, "tenant-id", "", "Tenant ID") cmd.Flags().StringSliceVar(&flags.cells, "cells", nil, "Cells to restrict the workflow to (comma-separated)") diff --git a/internal/cmd/branch/vtctld/move_tables_test.go b/internal/cmd/branch/vtctld/move_tables_test.go index ad1bccb45..b08d0bad8 100644 --- a/internal/cmd/branch/vtctld/move_tables_test.go +++ b/internal/cmd/branch/vtctld/move_tables_test.go @@ -83,6 +83,7 @@ func TestMoveTablesCreate(t *testing.T) { c.Assert(req.TabletTypes, qt.IsNil) c.Assert(req.ExcludeTables, qt.IsNil) c.Assert(req.TenantID, qt.Equals, "") + c.Assert(req.GlobalKeyspace, qt.Equals, "") c.Assert(req.AtomicCopy, qt.IsNil) return &ps.VtctldOperationReference{ID: "create-op"}, nil }, @@ -183,6 +184,8 @@ func TestMoveTablesCreateWithAllFlags(t *testing.T) { c.Assert(req.TabletTypes, qt.DeepEquals, []string{"PRIMARY", "REPLICA"}) c.Assert(req.ExcludeTables, qt.DeepEquals, []string{"t1", "t2"}) c.Assert(req.TenantID, qt.Equals, "tenant-123") + c.Assert(req.ShardedAutoIncrementHandling, qt.Equals, "REPLACE") + c.Assert(req.GlobalKeyspace, qt.Equals, "global") c.Assert(req.AtomicCopy, qt.IsNotNil) c.Assert(*req.AtomicCopy, qt.IsTrue) c.Assert(req.AllTables, qt.IsNotNil) @@ -215,6 +218,8 @@ func TestMoveTablesCreateWithAllFlags(t *testing.T) { "--tablet-types", "PRIMARY,REPLICA", "--exclude-tables", "t1,t2", "--tenant-id", "tenant-123", + "--sharded-auto-increment-handling", "REPLACE", + "--global-keyspace", "global", "--atomic-copy", }) err := cmd.Execute() From 2dcc8eca344f00a5a95be20e5648668b65da023a Mon Sep 17 00:00:00 2001 From: Matthias Crauwels Date: Thu, 9 Jul 2026 10:54:26 +0200 Subject: [PATCH 2/2] Bump planetscale-go to v0.178.0 Picks up MoveTablesCreateRequest.GlobalKeyspace, required for the --global-keyspace flag. Co-Authored-By: Claude Fable 5 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index ebc04f15c..ea744532d 100644 --- a/go.mod +++ b/go.mod @@ -32,7 +32,7 @@ require ( github.com/mitchellh/go-homedir v1.1.0 github.com/muesli/termenv v0.16.0 github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c - github.com/planetscale/planetscale-go v0.177.0 + github.com/planetscale/planetscale-go v0.178.0 github.com/planetscale/psdb v0.0.0-20250717190954-65c6661ab6e4 github.com/planetscale/psdbproxy v0.0.0-20250728082226-3f4ea3a74ec7 github.com/spf13/cobra v1.10.2 diff --git a/go.sum b/go.sum index c3147c644..d0867f25c 100644 --- a/go.sum +++ b/go.sum @@ -183,8 +183,8 @@ github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjL github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/planetscale/noglog v0.2.1-0.20210421230640-bea75fcd2e8e h1:MZ8D+Z3m2vvqGZLvoQfpaGg/j1fNDr4j03s3PRz4rVY= github.com/planetscale/noglog v0.2.1-0.20210421230640-bea75fcd2e8e/go.mod h1:hwAsSPQdvPa3WcfKfzTXxtEq/HlqwLjQasfO6QbGo4Q= -github.com/planetscale/planetscale-go v0.177.0 h1:jVE8uInjGayJ7RLaqwBK7VPgu96U/99dwV2MbbuRywA= -github.com/planetscale/planetscale-go v0.177.0/go.mod h1:paQCI5SgquuoewvMQM7R+r1XJO868bdP6/ihGidYRM0= +github.com/planetscale/planetscale-go v0.178.0 h1:1a+VwVpvV4eAFaeL1bLCPcnWKItuYTSBfD2s8BN+6To= +github.com/planetscale/planetscale-go v0.178.0/go.mod h1:paQCI5SgquuoewvMQM7R+r1XJO868bdP6/ihGidYRM0= github.com/planetscale/psdb v0.0.0-20250717190954-65c6661ab6e4 h1:Xv5pj20Rhfty1Tv0OVcidg4ez4PvGrpKvb6rvUwQgDs= github.com/planetscale/psdb v0.0.0-20250717190954-65c6661ab6e4/go.mod h1:M52h5IWxAcbdQ1hSZrLAGQC4ZXslxEsK/Wh9nu3wdWs= github.com/planetscale/psdbproxy v0.0.0-20250728082226-3f4ea3a74ec7 h1:aRd6vdE1fyuSI4RVj7oCr8lFmgqXvpnPUmN85VbZCp8=