Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions planetscale/vtctld_move_tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type MoveTablesCreateRequest struct {
DeferSecondaryKeys *bool `json:"defer_secondary_keys,omitempty"`
OnDDL string `json:"on_ddl,omitempty"`
ShardedAutoIncrementHandling string `json:"sharded_auto_increment_handling,omitempty"`
GlobalKeyspace string `json:"global_keyspace,omitempty"`
SourceTimeZone string `json:"source_time_zone,omitempty"`
TenantID string `json:"tenant_id,omitempty"`
Cells []string `json:"cells,omitempty"`
Expand Down
39 changes: 39 additions & 0 deletions planetscale/vtctld_move_tables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func TestMoveTables_Create(t *testing.T) {
_, hasTabletTypes := body["tablet_types"]
_, hasExcludeTables := body["exclude_tables"]
_, hasTenantID := body["tenant_id"]
_, hasGlobalKeyspace := body["global_keyspace"]
c.Assert(hasAllTables, qt.IsFalse)
c.Assert(hasAutoStart, qt.IsFalse)
c.Assert(hasStopAfterCopy, qt.IsFalse)
Expand All @@ -42,6 +43,7 @@ func TestMoveTables_Create(t *testing.T) {
c.Assert(hasTabletTypes, qt.IsFalse)
c.Assert(hasExcludeTables, qt.IsFalse)
c.Assert(hasTenantID, qt.IsFalse)
c.Assert(hasGlobalKeyspace, qt.IsFalse)

w.WriteHeader(http.StatusAccepted)
_, err = w.Write([]byte(`{"id":"create-op"}`))
Expand Down Expand Up @@ -100,6 +102,43 @@ func TestMoveTables_CreateWithTenantID(t *testing.T) {
c.Assert(ref, qt.DeepEquals, &VtctldOperationReference{ID: "create-op"})
}

func TestMoveTables_CreateWithGlobalKeyspace(t *testing.T) {
c := qt.New(t)

ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
c.Assert(r.Method, qt.Equals, http.MethodPost)
c.Assert(r.URL.Path, qt.Equals, "/v1/organizations/my-org/databases/my-db/branches/my-branch/move-tables/workflows")

var body map[string]interface{}
err := json.NewDecoder(r.Body).Decode(&body)
c.Assert(err, qt.IsNil)
c.Assert(body["global_keyspace"], qt.Equals, "global")
c.Assert(body["sharded_auto_increment_handling"], qt.Equals, "REPLACE")

w.WriteHeader(http.StatusAccepted)
_, err = w.Write([]byte(`{"id":"create-op"}`))
c.Assert(err, qt.IsNil)
}))
defer ts.Close()

client, err := NewClient(WithBaseURL(ts.URL))
c.Assert(err, qt.IsNil)

ctx := context.Background()
ref, err := client.MoveTables.Create(ctx, &MoveTablesCreateRequest{
Organization: "my-org",
Database: "my-db",
Branch: "my-branch",
Workflow: "my-workflow",
TargetKeyspace: "target",
SourceKeyspace: "source",
ShardedAutoIncrementHandling: "REPLACE",
GlobalKeyspace: "global",
})
c.Assert(err, qt.IsNil)
c.Assert(ref, qt.DeepEquals, &VtctldOperationReference{ID: "create-op"})
}

func TestMoveTables_CreateWithExplicitFalseValues(t *testing.T) {
c := qt.New(t)

Expand Down
Loading