Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: unify task payload (#15457)

Danny Xu6c1937faafce
diff --git a/backend/api/v1/issue_service.go b/backend/api/v1/issue_service.go
index bbb0565ee5..5b37d171ec 100644
--- a/backend/api/v1/issue_service.go
+++ b/backend/api/v1/issue_service.go
@@ -154,7 +154,6 @@ func (s *IssueService) getIssueFind(ctx context.Context, filter string, query st
case "DDL":
issueFind.TaskTypes = &[]api.TaskType{
api.TaskDatabaseSchemaUpdate,
- api.TaskDatabaseSchemaUpdateSDL,
api.TaskDatabaseSchemaUpdateGhost,
}
case "DML":
diff --git a/backend/api/v1/plan_service.go b/backend/api/v1/plan_service.go
index dbd125a5f3..cd3af571b2 100644
--- a/backend/api/v1/plan_service.go
+++ b/backend/api/v1/plan_service.go
@@ -2,7 +2,6 @@ package v1
import (
"context"
- "encoding/json"
"fmt"
"log/slog"
"slices"
@@ -409,13 +408,8 @@ func (s *PlanService) UpdatePlan(ctx context.Context, request *v1pb.UpdatePlanRe
}
tasksBySpecID := make(map[string][]*store.TaskMessage)
for _, task := range tasks {
- var taskSpecID struct {
- SpecID string `json:"specId"`
- }
- if err := json.Unmarshal([]byte(task.Payload), &taskSpecID); err != nil {
- return nil, status.Errorf(codes.Internal, "failed to unmarshal task payload: %v", err)
- }
- tasksBySpecID[taskSpecID.SpecID] = append(tasksBySpecID[taskSpecID.SpecID], task)
+ specID := task.Payload.GetSpecId()
+ tasksBySpecID[specID] = append(tasksBySpecID[specID], task)
}
for _, task := range tasks {
doUpdate := false
@@ -423,13 +417,8 @@ func (s *PlanService) UpdatePlan(ctx context.Context, request *v1pb.UpdatePlanRe
ID: task.ID,
UpdaterID: user.ID,
}
- var taskSpecID struct {
- SpecID string `json:"specId"`
- }
- if err := json.Unmarshal([]byte(task.Payload), &taskSpecID); err != nil {
- return nil, status.Errorf(codes.Internal, "failed to unmarshal task payload: %v", err)
- }
- spec, ok := updatedByID[taskSpecID.SpecID]
+ specID := task.Payload.GetSpecId()
+ spec, ok := updatedByID[specID]
if !ok {
continue
}
@@ -457,15 +446,11 @@ func (s *PlanService) UpdatePlan(ctx context.Context, request *v1pb.UpdatePlanRe
return nil
}
- payload := &storepb.TaskDatabaseUpdatePayload{}
- if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(task.Payload), payload); err != nil {
- return status.Errorf(codes.Internal, "failed to unmarshal task payload: %v", err)
- }
newFlags := spec.GetChangeDatabaseConfig().GetGhostFlags()
if _, err := ghost.GetUserFlags(newFlags); err != nil {
return status.Errorf(codes.InvalidArgument, "invalid ghost flags %q, error %v", newFlags, err)
}
- oldFlags := payload.Flags
+ oldFlags := task.Payload.GetFlags()
if cmp.Equal(oldFlags, newFlags) {
return nil
}
@@ -520,10 +505,6 @@ func (s *PlanService) UpdatePlan(ctx context.Context, request *v1pb.UpdatePlanRe
if newTaskType != api.TaskDatabaseDataUpdate {
return nil
}
- payload := &storepb.TaskDatabaseUpdatePayload{}
- if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(task.Payload), payload); err != nil {
- return status.Errorf(codes.Internal, "failed to unmarshal task payload: %v", err)
- }
config, ok := spec.Config.(*v1pb.Plan_Spec_ChangeDatabaseConfig)
if !ok {
return nil
@@ -533,12 +514,12 @@ func (s *PlanService) UpdatePlan(ctx context.Context, request *v1pb.UpdatePlanRe
// Format: instances/{instance}/databases/{database}
var backupDatabaseName *string
if config.ChangeDatabaseConfig.PreUpdateBackupDetail == nil {
- if payload.PreUpdateBackupDetail.Database != "" {
+ if task.Payload.GetPreUpdateBackupDetail().GetDatabase() != "" {
emptyValue := ""
backupDatabaseName = &emptyValue
}
} else {
- if config.ChangeDatabaseConfig.PreUpdateBackupDetail.Database != payload.PreUpdateBackupDetail.Database {
+ if config.ChangeDatabaseConfig.PreUpdateBackupDetail.Database != task.Payload.GetPreUpdateBackupDetail().GetDatabase() {
backupDatabaseName = &config.ChangeDatabaseConfig.PreUpdateBackupDetail.Database
}
}
@@ -586,14 +567,7 @@ func (s *PlanService) UpdatePlan(ctx context.Context, request *v1pb.UpdatePlanRe
// Sheet
if err := func() error {
switch newTaskType {
- case api.TaskDatabaseSchemaUpdate, api.TaskDatabaseSchemaUpdateSDL, api.TaskDatabaseSchemaUpdateGhost, api.TaskDatabaseDataUpdate, api.TaskDatabaseDataExport:
- var taskPayload struct {
- SheetID int `json:"sheetId"`
- }
- if err := json.Unmarshal([]byte(task.Payload), &taskPayload); err != nil {
- return status.Errorf(codes.Internal, "failed to unmarshal task payload: %v", err)
- }
-
+ case api.TaskDatabaseSchemaUpdate, api.TaskDatabaseSchemaUpdateGhost, api.TaskDatabaseDataUpdate, api.TaskDatabaseDataExport:
var oldSheetName string
if newTaskType == api.TaskDatabaseDataExport {
config, ok := spec.Config.(*v1pb.Plan_Spec_ExportDataConfig)
@@ -612,7 +586,7 @@ func (s *PlanService) UpdatePlan(ctx context.Context, request *v1pb.UpdatePlanRe
if err != nil {
return status.Errorf(codes.Internal, "failed to get sheet id from %q, error: %v", oldSheetName, err)
}
- if taskPayload.SheetID == sheetUID {
+ if int(task.Payload.GetSheetId()) == sheetUID {
return nil
}
@@ -629,7 +603,7 @@ func (s *PlanService) UpdatePlan(ctx context.Context, request *v1pb.UpdatePlanRe
taskPatch.SheetID = &sheet.UID
if issue != nil {
- oldSheet := common.FormatSheet(issue.Project.ResourceID, taskPayload.SheetID)
+ oldSheet := common.FormatSheet(issue.Project.ResourceID, int(task.Payload.GetSheetId()))
newSheet := common.FormatSheet(issue.Project.ResourceID, sheet.UID)
issueCommentCreates = append(issueCommentCreates, &store.IssueCommentMessage{
IssueUID: issue.UID,
@@ -655,20 +629,16 @@ func (s *PlanService) UpdatePlan(ctx context.Context, request *v1pb.UpdatePlanRe
if newTaskType != api.TaskDatabaseDataExport {
return nil
}
- payload := &storepb.TaskDatabaseDataExportPayload{}
- if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(task.Payload), payload); err != nil {
- return status.Errorf(codes.Internal, "failed to unmarshal task payload: %v", err)
- }
config, ok := spec.Config.(*v1pb.Plan_Spec_ExportDataConfig)
if !ok {
return nil
}
- if config.ExportDataConfig.Format != convertExportFormat(payload.Format) {
+ if config.ExportDataConfig.Format != convertExportFormat(task.Payload.GetFormat()) {
format := convertToExportFormat(config.ExportDataConfig.Format)
taskPatch.ExportFormat = &format
doUpdate = true
}
- if (config.ExportDataConfig.Password == nil && payload.Password != "") || (config.ExportDataConfig.Password != nil && *config.ExportDataConfig.Password != payload.Password) {
+ if (config.ExportDataConfig.Password == nil && task.Payload.GetPassword() != "") || (config.ExportDataConfig.Password != nil && *config.ExportDataConfig.Password != task.Payload.GetPassword()) {
taskPatch.ExportPassword = config.ExportDataConfig.Password
doUpdate = true
}
@@ -680,17 +650,11 @@ func (s *PlanService) UpdatePlan(ctx context.Context, request *v1pb.UpdatePlanRe
// version
if err := func() error {
switch newTaskType {
- case api.TaskDatabaseSchemaBaseline, api.TaskDatabaseSchemaUpdate, api.TaskDatabaseSchemaUpdateSDL, api.TaskDatabaseSchemaUpdateGhost, api.TaskDatabaseDataUpdate:
+ case api.TaskDatabaseSchemaBaseline, api.TaskDatabaseSchemaUpdate, api.TaskDatabaseSchemaUpdateGhost, api.TaskDatabaseDataUpdate:
default:
return nil
}
- var taskPayload struct {
- SchemaVersion string `json:"schemaVersion"`
- }
- if err := json.Unmarshal([]byte(task.Payload), &taskPayload); err != nil {
- return errors.Wrapf(err, "failed to unmarshal task payload")
- }
- if v := spec.GetChangeDatabaseConfig().GetSchemaVersion(); v != "" && v != taskPayload.SchemaVersion {
+ if v := spec.GetChangeDatabaseConfig().GetSchemaVersion(); v != "" && v != task.Payload.GetSchemaVersion() {
taskPatch.SchemaVersion = &v
doUpdate = true
}
@@ -1418,8 +1382,6 @@ func getTaskTypeFromSpec(spec *v1pb.Plan_Spec) (api.TaskType, error) {
return api.TaskDatabaseSchemaUpdate, nil
case v1pb.Plan_ChangeDatabaseConfig_MIGRATE_GHOST:
return api.TaskDatabaseSchemaUpdateGhost, nil
- case v1pb.Plan_ChangeDatabaseConfig_MIGRATE_SDL:
- return api.TaskDatabaseSchemaUpdateSDL, nil
}
case *v1pb.Plan_Spec_ExportDataConfig:
return api.TaskDatabaseDataExport, nil
diff --git a/backend/api/v1/plan_service_plan_check.go b/backend/api/v1/plan_service_plan_check.go
index 5dfeaea0b5..f50fb178a2 100644
--- a/backend/api/v1/plan_service_plan_check.go
+++ b/backend/api/v1/plan_service_plan_check.go
@@ -2,7 +2,6 @@ package v1
import (
"context"
- "encoding/json"
"github.com/pkg/errors"
@@ -22,14 +21,8 @@ func getPlanCheckRunsFromPlan(ctx context.Context, s *store.Store, plan *store.P
}
skippedSpecIDs = make(map[string]struct{})
for _, task := range tasks {
- var taskSpecID struct {
- SpecID string `json:"specId"`
- }
- if err := json.Unmarshal([]byte(task.Payload), &taskSpecID); err != nil {
- return nil, errors.Wrapf(err, "failed to unmarshal task payload")
- }
if task.LatestTaskRunStatus == api.TaskRunDone {
- skippedSpecIDs[taskSpecID.SpecID] = struct{}{}
+ skippedSpecIDs[task.Payload.GetSpecId()] = struct{}{}
}
}
}
diff --git a/backend/api/v1/rollout_service.go b/backend/api/v1/rollout_service.go
index 3aed0c3d1a..ca410861cd 100644
--- a/backend/api/v1/rollout_service.go
+++ b/backend/api/v1/rollout_service.go
@@ -578,13 +578,10 @@ func (s *RolloutService) BatchRunTasks(ctx context.Context, request *v1pb.BatchR
continue
}
- sheetUID, err := api.GetSheetUIDFromTaskPayload(task.Payload)
- if err != nil {
- return nil, status.Errorf(codes.Internal, "failed to get sheet uid from task payload, error: %v", err)
- }
+ sheetUID := int(task.Payload.GetSheetId())
create := &store.TaskRunMessage{
TaskUID: task.ID,
- SheetUID: sheetUID,
+ SheetUID: &sheetUID,
CreatorID: user.ID,
}
taskRunCreates = append(taskRunCreates, create)
diff --git a/backend/api/v1/rollout_service_converter.go b/backend/api/v1/rollout_service_converter.go
index 116296c12e..a0a9d7850e 100644
--- a/backend/api/v1/rollout_service_converter.go
+++ b/backend/api/v1/rollout_service_converter.go
@@ -694,7 +694,7 @@ func convertToTask(ctx context.Context, s *store.Store, project *store.ProjectMe
return convertToTaskFromDatabaseCreate(ctx, s, project, task)
case api.TaskDatabaseSchemaBaseline:
return convertToTaskFromSchemaBaseline(ctx, s, project, task)
- case api.TaskDatabaseSchemaUpdate, api.TaskDatabaseSchemaUpdateSDL, api.TaskDatabaseSchemaUpdateGhost:
+ case api.TaskDatabaseSchemaUpdate, api.TaskDatabaseSchemaUpdateGhost:
return convertToTaskFromSchemaUpdate(ctx, s, project, task)
case api.TaskDatabaseDataUpdate:
return convertToTaskFromDataUpdate(ctx, s, project, task)
@@ -706,10 +706,6 @@ func convertToTask(ctx context.Context, s *store.Store, project *store.ProjectMe
}
func convertToTaskFromDatabaseCreate(ctx context.Context, s *store.Store, project *store.ProjectMessage, task *store.TaskMessage) (*v1pb.Task, error) {
- payload := &storepb.TaskDatabaseCreatePayload{}
- if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(task.Payload), payload); err != nil {
- return nil, errors.Wrapf(err, "failed to unmarshal task payload")
- }
instance, err := s.GetInstanceV2(ctx, &store.FindInstanceMessage{
ResourceID: &task.InstanceID,
})
@@ -718,20 +714,20 @@ func convertToTaskFromDatabaseCreate(ctx context.Context, s *store.Store, projec
}
v1pbTask := &v1pb.Task{
Name: common.FormatTask(project.ResourceID, task.PipelineID, task.StageID, task.ID),
- SpecId: payload.SpecId,
+ SpecId: task.Payload.GetSpecId(),
Type: convertToTaskType(task.Type),
- Status: convertToTaskStatus(task.LatestTaskRunStatus, payload.Skipped),
- SkippedReason: payload.SkippedReason,
+ Status: convertToTaskStatus(task.LatestTaskRunStatus, task.Payload.GetSkipped()),
+ SkippedReason: task.Payload.GetSkippedReason(),
Target: common.FormatInstance(instance.ResourceID),
Payload: &v1pb.Task_DatabaseCreate_{
DatabaseCreate: &v1pb.Task_DatabaseCreate{
Project: "",
- Database: payload.DatabaseName,
- Table: payload.TableName,
- Sheet: common.FormatSheet(project.ResourceID, int(payload.SheetId)),
- CharacterSet: payload.CharacterSet,
- Collation: payload.Collation,
- Environment: common.FormatEnvironment(payload.EnvironmentId),
+ Database: task.Payload.GetDatabaseName(),
+ Table: task.Payload.GetTableName(),
+ Sheet: common.FormatSheet(project.ResourceID, int(task.Payload.GetSheetId())),
+ CharacterSet: task.Payload.GetCharacterSet(),
+ Collation: task.Payload.GetCollation(),
+ Environment: common.FormatEnvironment(task.Payload.GetEnvironmentId()),
},
},
}
@@ -743,10 +739,6 @@ func convertToTaskFromSchemaBaseline(ctx context.Context, s *store.Store, projec
if task.DatabaseName == nil {
return nil, errors.Errorf("baseline task database is nil")
}
- payload := &storepb.TaskDatabaseUpdatePayload{}
- if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(task.Payload), payload); err != nil {
- return nil, errors.Wrapf(err, "failed to unmarshal task payload")
- }
database, err := s.GetDatabaseV2(ctx, &store.FindDatabaseMessage{InstanceID: &task.InstanceID, DatabaseName: task.DatabaseName, ShowDeleted: true})
if err != nil {
return nil, errors.Wrapf(err, "failed to get database")
@@ -756,14 +748,14 @@ func convertToTaskFromSchemaBaseline(ctx context.Context, s *store.Store, projec
}
v1pbTask := &v1pb.Task{
Name: common.FormatTask(project.ResourceID, task.PipelineID, task.StageID, task.ID),
- SpecId: payload.SpecId,
+ SpecId: task.Payload.GetSpecId(),
Type: convertToTaskType(task.Type),
- Status: convertToTaskStatus(task.LatestTaskRunStatus, payload.Skipped),
- SkippedReason: payload.SkippedReason,
+ Status: convertToTaskStatus(task.LatestTaskRunStatus, task.Payload.GetSkipped()),
+ SkippedReason: task.Payload.GetSkippedReason(),
Target: fmt.Sprintf("%s%s/%s%s", common.InstanceNamePrefix, database.InstanceID, common.DatabaseIDPrefix, database.DatabaseName),
Payload: &v1pb.Task_DatabaseSchemaBaseline_{
DatabaseSchemaBaseline: &v1pb.Task_DatabaseSchemaBaseline{
- SchemaVersion: payload.SchemaVersion,
+ SchemaVersion: task.Payload.GetSchemaVersion(),
},
},
}
@@ -774,10 +766,6 @@ func convertToTaskFromSchemaUpdate(ctx context.Context, s *store.Store, project
if task.DatabaseName == nil {
return nil, errors.Errorf("schema update task database is nil")
}
- payload := &storepb.TaskDatabaseUpdatePayload{}
- if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(task.Payload), payload); err != nil {
- return nil, errors.Wrapf(err, "failed to unmarshal task payload")
- }
database, err := s.GetDatabaseV2(ctx, &store.FindDatabaseMessage{InstanceID: &task.InstanceID, DatabaseName: task.DatabaseName, ShowDeleted: true})
if err != nil {
return nil, errors.Wrapf(err, "failed to get database")
@@ -788,15 +776,15 @@ func convertToTaskFromSchemaUpdate(ctx context.Context, s *store.Store, project
v1pbTask := &v1pb.Task{
Name: common.FormatTask(project.ResourceID, task.PipelineID, task.StageID, task.ID),
- SpecId: payload.SpecId,
+ SpecId: task.Payload.GetSpecId(),
Type: convertToTaskType(task.Type),
- Status: convertToTaskStatus(task.LatestTaskRunStatus, payload.Skipped),
- SkippedReason: payload.SkippedReason,
+ Status: convertToTaskStatus(task.LatestTaskRunStatus, task.Payload.GetSkipped()),
+ SkippedReason: task.Payload.GetSkippedReason(),
Target: fmt.Sprintf("%s%s/%s%s", common.InstanceNamePrefix, database.InstanceID, common.DatabaseIDPrefix, database.DatabaseName),
Payload: &v1pb.Task_DatabaseSchemaUpdate_{
DatabaseSchemaUpdate: &v1pb.Task_DatabaseSchemaUpdate{
- Sheet: common.FormatSheet(project.ResourceID, int(payload.SheetId)),
- SchemaVersion: payload.SchemaVersion,
+ Sheet: common.FormatSheet(project.ResourceID, int(task.Payload.GetSheetId())),
+ SchemaVersion: task.Payload.GetSchemaVersion(),
},
},
}
@@ -807,10 +795,6 @@ func convertToTaskFromDataUpdate(ctx context.Context, s *store.Store, project *s
if task.DatabaseName == nil {
return nil, errors.Errorf("data update task database is nil")
}
- payload := &storepb.TaskDatabaseUpdatePayload{}
- if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(task.Payload), payload); err != nil {
- return nil, errors.Wrapf(err, "failed to unmarshal task payload")
- }
database, err := s.GetDatabaseV2(ctx, &store.FindDatabaseMessage{InstanceID: &task.InstanceID, DatabaseName: task.DatabaseName, ShowDeleted: true})
if err != nil {
return nil, errors.Wrapf(err, "failed to get database")
@@ -821,17 +805,17 @@ func convertToTaskFromDataUpdate(ctx context.Context, s *store.Store, project *s
v1pbTask := &v1pb.Task{
Name: common.FormatTask(project.ResourceID, task.PipelineID, task.StageID, task.ID),
- SpecId: payload.SpecId,
+ SpecId: task.Payload.GetSpecId(),
Type: convertToTaskType(task.Type),
- Status: convertToTaskStatus(task.LatestTaskRunStatus, payload.Skipped),
- SkippedReason: payload.SkippedReason,
+ Status: convertToTaskStatus(task.LatestTaskRunStatus, task.Payload.GetSkipped()),
+ SkippedReason: task.Payload.GetSkippedReason(),
Target: fmt.Sprintf("%s%s/%s%s", common.InstanceNamePrefix, database.InstanceID, common.DatabaseIDPrefix, database.DatabaseName),
Payload: nil,
}
v1pbTaskPayload := &v1pb.Task_DatabaseDataUpdate_{
DatabaseDataUpdate: &v1pb.Task_DatabaseDataUpdate{
- Sheet: common.FormatSheet(project.ResourceID, int(payload.SheetId)),
- SchemaVersion: payload.SchemaVersion,
+ Sheet: common.FormatSheet(project.ResourceID, int(task.Payload.GetSheetId())),
+ SchemaVersion: task.Payload.GetSchemaVersion(),
},
}
@@ -843,10 +827,6 @@ func convertToTaskFromDatabaseDataExport(ctx context.Context, s *store.Store, pr
if task.DatabaseName == nil {
return nil, errors.Errorf("data export task database is nil")
}
- payload := &storepb.TaskDatabaseDataExportPayload{}
- if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(task.Payload), payload); err != nil {
- return nil, errors.Wrapf(err, "failed to unmarshal task payload")
- }
database, err := s.GetDatabaseV2(ctx, &store.FindDatabaseMessage{InstanceID: &task.InstanceID, DatabaseName: task.DatabaseName, ShowDeleted: true})
if err != nil {
return nil, errors.Wrapf(err, "failed to get database")
@@ -855,18 +835,18 @@ func convertToTaskFromDatabaseDataExport(ctx context.Context, s *store.Store, pr
return nil, errors.Errorf("database not found")
}
targetDatabaseName := fmt.Sprintf("%s%s/%s%s", common.InstanceNamePrefix, database.InstanceID, common.DatabaseIDPrefix, database.DatabaseName)
- sheet := common.FormatSheet(project.ResourceID, int(payload.SheetId))
+ sheet := common.FormatSheet(project.ResourceID, int(task.Payload.GetSheetId()))
v1pbTaskPayload := v1pb.Task_DatabaseDataExport_{
DatabaseDataExport: &v1pb.Task_DatabaseDataExport{
Target: targetDatabaseName,
Sheet: sheet,
- Format: convertExportFormat(payload.Format),
- Password: &payload.Password,
+ Format: convertExportFormat(task.Payload.GetFormat()),
+ Password: &task.Payload.Password,
},
}
v1pbTask := &v1pb.Task{
Name: common.FormatTask(project.ResourceID, task.PipelineID, task.StageID, task.ID),
- SpecId: payload.SpecId,
+ SpecId: task.Payload.GetSpecId(),
Type: convertToTaskType(task.Type),
Status: convertToTaskStatus(task.LatestTaskRunStatus, false),
Target: targetDatabaseName,
@@ -905,8 +885,6 @@ func convertToTaskType(taskType api.TaskType) v1pb.Task_Type {
return v1pb.Task_DATABASE_SCHEMA_BASELINE
case api.TaskDatabaseSchemaUpdate:
return v1pb.Task_DATABASE_SCHEMA_UPDATE
- case api.TaskDatabaseSchemaUpdateSDL:
- return v1pb.Task_DATABASE_SCHEMA_UPDATE_SDL
case api.TaskDatabaseSchemaUpdateGhost:
return v1pb.Task_DATABASE_SCHEMA_UPDATE_GHOST
case api.TaskDatabaseDataUpdate:
diff --git a/backend/api/v1/rollout_service_task.go b/backend/api/v1/rollout_service_task.go
index 02a2ecb3f7..4001d75c8b 100644
--- a/backend/api/v1/rollout_service_task.go
+++ b/backend/api/v1/rollout_service_task.go
@@ -8,7 +8,6 @@ import (
"log/slog"
"github.com/pkg/errors"
- "google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
"github.com/bytebase/bytebase/backend/common"
@@ -231,26 +230,20 @@ func getTaskCreatesFromCreateDatabaseConfig(ctx context.Context, s *store.Store,
return nil, errors.Wrap(err, "failed to create database creation sheet")
}
- payload := &storepb.TaskDatabaseCreatePayload{
- SpecId: spec.Id,
- CharacterSet: c.CharacterSet,
- TableName: c.Table,
- Collation: c.Collation,
- EnvironmentId: dbEnvironmentID,
- DatabaseName: databaseName,
- SheetId: int32(sheet.UID),
- }
- bytes, err := protojson.Marshal(payload)
- if err != nil {
- return nil, errors.Wrap(err, "failed to create database creation task, unable to marshal payload")
- }
-
v := &store.TaskMessage{
InstanceID: instance.ResourceID,
DatabaseName: &databaseName,
EnvironmentID: effectiveEnvironmentID,
Type: api.TaskDatabaseCreate,
- Payload: string(bytes),
+ Payload: &storepb.TaskPayload{
+ SpecId: spec.Id,
+ CharacterSet: c.CharacterSet,
+ TableName: c.Table,
+ Collation: c.Collation,
+ EnvironmentId: dbEnvironmentID,
+ DatabaseName: databaseName,
+ SheetId: int32(sheet.UID),
+ },
}
if spec.EarliestAllowedTime.GetSeconds() > 0 {
t := spec.EarliestAllowedTime.AsTime()
@@ -312,7 +305,7 @@ func getTaskCreatesFromExportDataConfig(ctx context.Context, s *store.Store, spe
if err != nil {
return nil, errors.Wrapf(err, "failed to get sheet id from sheet %q", c.Sheet)
}
- payload := &storepb.TaskDatabaseDataExportPayload{
+ payload := &storepb.TaskPayload{
SpecId: spec.Id,
SheetId: int32(sheetUID),
Format: c.Format,
@@ -320,17 +313,12 @@ func getTaskCreatesFromExportDataConfig(ctx context.Context, s *store.Store, spe
if c.Password != nil {
payload.Password = *c.Password
}
- bytes, err := protojson.Marshal(payload)
- if err != nil {
- return nil, errors.Wrapf(err, "failed to marshal task database data export payload")
- }
- payloadString := string(bytes)
taskCreate := &store.TaskMessage{
InstanceID: database.InstanceID,
DatabaseName: &database.DatabaseName,
EnvironmentID: database.EffectiveEnvironmentID,
Type: api.TaskDatabaseDataExport,
- Payload: payloadString,
+ Payload: payload,
}
if spec.EarliestAllowedTime.GetSeconds() > 0 {
t := spec.EarliestAllowedTime.AsTime()
@@ -368,24 +356,18 @@ func getTaskCreatesFromChangeDatabaseConfigDatabaseTarget(ctx context.Context, s
switch c.Type {
case storepb.PlanConfig_ChangeDatabaseConfig_BASELINE:
- payload := &storepb.TaskDatabaseUpdatePayload{
- SpecId: spec.Id,
- SchemaVersion: c.SchemaVersion,
- TaskReleaseSource: &storepb.TaskReleaseSource{
- File: spec.SpecReleaseSource.GetFile(),
- },
- }
- bytes, err := protojson.Marshal(payload)
- if err != nil {
- return nil, errors.Wrapf(err, "failed to marshal task database schema baseline payload")
- }
- payloadString := string(bytes)
taskCreate := &store.TaskMessage{
InstanceID: database.InstanceID,
DatabaseName: &database.DatabaseName,
EnvironmentID: database.EffectiveEnvironmentID,
Type: api.TaskDatabaseSchemaBaseline,
- Payload: payloadString,
+ Payload: &storepb.TaskPayload{
+ SpecId: spec.Id,
+ SchemaVersion: c.SchemaVersion,
+ TaskReleaseSource: &storepb.TaskReleaseSource{
+ File: spec.SpecReleaseSource.GetFile(),
+ },
+ },
}
if spec.EarliestAllowedTime.GetSeconds() > 0 {
t := spec.EarliestAllowedTime.AsTime()
@@ -398,57 +380,20 @@ func getTaskCreatesFromChangeDatabaseConfigDatabaseTarget(ctx context.Context, s
if err != nil {
return nil, errors.Wrapf(err, "failed to get sheet id from sheet %q", c.Sheet)
}
- payload := &storepb.TaskDatabaseUpdatePayload{
- SpecId: spec.Id,
- SheetId: int32(sheetUID),
- SchemaVersion: c.SchemaVersion,
- TaskReleaseSource: &storepb.TaskReleaseSource{
- File: spec.SpecReleaseSource.GetFile(),
- },
- }
- bytes, err := protojson.Marshal(payload)
- if err != nil {
- return nil, errors.Wrapf(err, "failed to marshal task database schema update payload")
- }
- payloadString := string(bytes)
taskCreate := &store.TaskMessage{
InstanceID: database.InstanceID,
DatabaseName: &database.DatabaseName,
EnvironmentID: database.EffectiveEnvironmentID,
Type: api.TaskDatabaseSchemaUpdate,
- Payload: payloadString,
- }
- if spec.EarliestAllowedTime.GetSeconds() > 0 {
- t := spec.EarliestAllowedTime.AsTime()
- taskCreate.EarliestAllowedAt = &t
- }
- return []*store.TaskMessage{taskCreate}, nil
-
- case storepb.PlanConfig_ChangeDatabaseConfig_MIGRATE_SDL:
- _, sheetUID, err := common.GetProjectResourceIDSheetUID(c.Sheet)
- if err != nil {
- return nil, errors.Wrapf(err, "failed to get sheet id from sheet %q", c.Sheet)
- }
- payload := &storepb.TaskDatabaseUpdatePayload{
- SpecId: spec.Id,
- SheetId: int32(sheetUID),
- SchemaVersion: c.SchemaVersion,
- TaskReleaseSource: &storepb.TaskReleaseSource{
- File: spec.SpecReleaseSource.GetFile(),
+ Payload: &storepb.TaskPayload{
+ SpecId: spec.Id,
+ SheetId: int32(sheetUID),
+ SchemaVersion: c.SchemaVersion,
+ TaskReleaseSource: &storepb.TaskReleaseSource{
+ File: spec.SpecReleaseSource.GetFile(),
+ },
},
}
- bytes, err := protojson.Marshal(payload)
- if err != nil {
- return nil, errors.Wrapf(err, "failed to marshal database schema update SDL payload")
- }
- payloadString := string(bytes)
- taskCreate := &store.TaskMessage{
- InstanceID: database.InstanceID,
- DatabaseName: &database.DatabaseName,
- EnvironmentID: database.EffectiveEnvironmentID,
- Type: api.TaskDatabaseSchemaUpdateSDL,
- Payload: payloadString,
- }
if spec.EarliestAllowedTime.GetSeconds() > 0 {
t := spec.EarliestAllowedTime.AsTime()
taskCreate.EarliestAllowedAt = &t
@@ -463,25 +408,20 @@ func getTaskCreatesFromChangeDatabaseConfigDatabaseTarget(ctx context.Context, s
if _, err := ghost.GetUserFlags(c.GhostFlags); err != nil {
return nil, errors.Wrapf(err, "invalid ghost flags %q", c.GhostFlags)
}
- payload := &storepb.TaskDatabaseUpdatePayload{
- SpecId: spec.Id,
- SheetId: int32(sheetUID),
- SchemaVersion: c.SchemaVersion,
- Flags: c.GhostFlags,
- TaskReleaseSource: &storepb.TaskReleaseSource{
- File: spec.SpecReleaseSource.GetFile(),
- },
- }
- bytes, err := protojson.Marshal(payload)
- if err != nil {
- return nil, errors.Wrapf(err, "failed to marshal database schema update ghost payload")
- }
taskCreate := &store.TaskMessage{
InstanceID: database.InstanceID,
DatabaseName: &database.DatabaseName,
EnvironmentID: database.EffectiveEnvironmentID,
Type: api.TaskDatabaseSchemaUpdateGhost,
- Payload: string(bytes),
+ Payload: &storepb.TaskPayload{
+ SpecId: spec.Id,
+ SheetId: int32(sheetUID),
+ SchemaVersion: c.SchemaVersion,
+ Flags: c.GhostFlags,
+ TaskReleaseSource: &storepb.TaskReleaseSource{
+ File: spec.SpecReleaseSource.GetFile(),
+ },
+ },
}
if spec.EarliestAllowedTime.GetSeconds() > 0 {
t := spec.EarliestAllowedTime.AsTime()
@@ -498,26 +438,20 @@ func getTaskCreatesFromChangeDatabaseConfigDatabaseTarget(ctx context.Context, s
if c.GetPreUpdateBackupDetail().GetDatabase() != "" {
preUpdateBackupDetail.Database = c.GetPreUpdateBackupDetail().GetDatabase()
}
- payload := &storepb.TaskDatabaseUpdatePayload{
- SpecId: spec.Id,
- SheetId: int32(sheetUID),
- SchemaVersion: c.SchemaVersion,
- PreUpdateBackupDetail: preUpdateBackupDetail,
- TaskReleaseSource: &storepb.TaskReleaseSource{
- File: spec.SpecReleaseSource.GetFile(),
- },
- }
- bytes, err := protojson.Marshal(payload)
- if err != nil {
- return nil, errors.Wrapf(err, "Failed to marshal database data update payload")
- }
- payloadString := string(bytes)
taskCreate := &store.TaskMessage{
InstanceID: database.InstanceID,
DatabaseName: &database.DatabaseName,
EnvironmentID: database.EffectiveEnvironmentID,
Type: api.TaskDatabaseDataUpdate,
- Payload: payloadString,
+ Payload: &storepb.TaskPayload{
+ SpecId: spec.Id,
+ SheetId: int32(sheetUID),
+ SchemaVersion: c.SchemaVersion,
+ PreUpdateBackupDetail: preUpdateBackupDetail,
+ TaskReleaseSource: &storepb.TaskReleaseSource{
+ File: spec.SpecReleaseSource.GetFile(),
+ },
+ },
}
if spec.EarliestAllowedTime.GetSeconds() > 0 {
t := spec.EarliestAllowedTime.AsTime()
diff --git a/backend/legacyapi/task.go b/backend/legacyapi/task.go
index 246bf663ac..86fd8c5ee5 100644
--- a/backend/legacyapi/task.go
+++ b/backend/legacyapi/task.go
@@ -1,11 +1,5 @@
package api
-import (
- "encoding/json"
-
- "github.com/pkg/errors"
-)
-
// TaskStatus is the status of a task.
type TaskStatus string
@@ -36,8 +30,6 @@ const (
TaskDatabaseSchemaBaseline TaskType = "bb.task.database.schema.baseline"
// TaskDatabaseSchemaUpdate is the task type for updating database schemas.
TaskDatabaseSchemaUpdate TaskType = "bb.task.database.schema.update"
- // TaskDatabaseSchemaUpdateSDL is the task type for updating database schemas via state-based migration.
- TaskDatabaseSchemaUpdateSDL TaskType = "bb.task.database.schema.update-sdl"
// TaskDatabaseSchemaUpdateGhost is the task type for updating database schemas using gh-ost.
TaskDatabaseSchemaUpdateGhost TaskType = "bb.task.database.schema.update-ghost"
// TaskDatabaseDataUpdate is the task type for updating database data.
@@ -51,7 +43,6 @@ func (t TaskType) ChangeDatabasePayload() bool {
case
TaskDatabaseDataUpdate,
TaskDatabaseSchemaUpdate,
- TaskDatabaseSchemaUpdateSDL,
TaskDatabaseSchemaUpdateGhost,
TaskDatabaseSchemaBaseline:
return true
@@ -65,42 +56,9 @@ func (t TaskType) Sequential() bool {
switch t {
case
TaskDatabaseSchemaUpdate,
- TaskDatabaseSchemaUpdateSDL,
TaskDatabaseSchemaUpdateGhost:
return true
default:
return false
}
}
-
-// These payload types are only used when marshalling to the json format for saving into the database.
-// So we annotate with json tag using camelCase naming which is consistent with normal
-// json naming convention
-
-// Progress is a generalized struct which can track the progress of a task.
-type Progress struct {
- // TotalUnit is the total unit count of the task
- TotalUnit int64 `json:"totalUnit"`
- // CompletedUnit is the finished task units
- CompletedUnit int64 `json:"completedUnit"`
- // CreatedTs is when the task starts
- CreatedTs int64 `json:"createdTs"`
- // UpdatedTs is when the progress gets updated most recently
- UpdatedTs int64 `json:"updatedTs"`
- // Payload is reserved for the future
- // Might be something like {comment:"postponing due to network lag"}
- Payload string `json:"payload"`
-}
-
-func GetSheetUIDFromTaskPayload(payload string) (*int, error) {
- var taskPayload struct {
- SheetID int `json:"sheetId"`
- }
- if err := json.Unmarshal([]byte(payload), &taskPayload); err != nil {
- return nil, errors.Wrapf(err, "failed to unmarshal task payload")
- }
- if taskPayload.SheetID == 0 {
- return nil, nil
- }
- return &taskPayload.SheetID, nil
-}
diff --git a/backend/runner/approval/runner.go b/backend/runner/approval/runner.go
index 29e81ad10d..b0e14e6f2b 100644
--- a/backend/runner/approval/runner.go
+++ b/backend/runner/approval/runner.go
@@ -434,14 +434,11 @@ func (r *Runner) getDatabaseGeneralIssueRisk(ctx context.Context, issue *store.I
}
taskStatement := ""
- sheetUID, err := api.GetSheetUIDFromTaskPayload(task.Payload)
- if err != nil {
- return 0, store.RiskSourceUnknown, true, errors.Wrapf(err, "failed to get sheet id in task %v", task.ID)
- }
- if sheetUID != nil {
- statement, err := r.store.GetSheetStatementByID(ctx, *sheetUID)
+ sheetUID := int(task.Payload.GetSheetId())
+ if sheetUID != 0 {
+ statement, err := r.store.GetSheetStatementByID(ctx, sheetUID)
if err != nil {
- return 0, store.RiskSourceUnknown, true, errors.Wrapf(err, "failed to get statement in sheet %v", *sheetUID)
+ return 0, store.RiskSourceUnknown, true, errors.Wrapf(err, "failed to get statement in sheet %v", sheetUID)
}
taskStatement = statement
}
@@ -449,14 +446,8 @@ func (r *Runner) getDatabaseGeneralIssueRisk(ctx context.Context, issue *store.I
environmentID := instance.EnvironmentID
var databaseName string
if task.Type == api.TaskDatabaseCreate {
- payload := &storepb.TaskDatabaseCreatePayload{}
- if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(task.Payload), payload); err != nil {
- return 0, store.RiskSourceUnknown, false, err
- }
- databaseName = payload.DatabaseName
- if payload.EnvironmentId != "" {
- environmentID = payload.EnvironmentId
- }
+ databaseName = task.Payload.GetDatabaseName()
+ environmentID = task.Payload.GetEnvironmentId()
} else {
database, err := r.store.GetDatabaseV2(ctx, &store.FindDatabaseMessage{
InstanceID: &task.InstanceID,
@@ -615,11 +606,6 @@ func (r *Runner) getDatabaseDataExportIssueRisk(ctx context.Context, issue *stor
return 0, store.RiskSourceUnknown, true, nil
}
- payload := &storepb.TaskDatabaseDataExportPayload{}
- if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(task.Payload), payload); err != nil {
- return 0, store.RiskSourceUnknown, false, err
- }
-
database, err := r.store.GetDatabaseV2(ctx, &store.FindDatabaseMessage{
InstanceID: &task.InstanceID,
DatabaseName: task.DatabaseName,
diff --git a/backend/runner/taskrun/data_export_executor.go b/backend/runner/taskrun/data_export_executor.go
index 3e4c3fcbbe..f67e54c3ca 100644
--- a/backend/runner/taskrun/data_export_executor.go
+++ b/backend/runner/taskrun/data_export_executor.go
@@ -42,11 +42,6 @@ type DataExportExecutor struct {
// RunOnce will run the data export task executor once.
func (exec *DataExportExecutor) RunOnce(ctx context.Context, _ context.Context, task *store.TaskMessage, _ int) (terminated bool, result *storepb.TaskRunResult, err error) {
- payload := &storepb.TaskDatabaseDataExportPayload{}
- if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(task.Payload), payload); err != nil {
- return true, nil, errors.Wrap(err, "invalid database data export payload")
- }
-
issue, err := exec.store.GetIssueV2(ctx, &store.FindIssueMessage{PipelineID: &task.PipelineID})
if err != nil {
return true, nil, errors.Wrapf(err, "failed to get issue")
@@ -67,7 +62,7 @@ func (exec *DataExportExecutor) RunOnce(ctx context.Context, _ context.Context,
return true, nil, errors.Errorf("instance not found")
}
- statement, err := exec.store.GetSheetStatementByID(ctx, int(payload.SheetId))
+ statement, err := exec.store.GetSheetStatementByID(ctx, int(task.Payload.GetSheetId()))
if err != nil {
return true, nil, err
}
@@ -75,8 +70,8 @@ func (exec *DataExportExecutor) RunOnce(ctx context.Context, _ context.Context,
exportRequest := &v1pb.ExportRequest{
Name: common.FormatDatabase(instance.ResourceID, database.DatabaseName),
Statement: statement,
- Format: v1pb.ExportFormat(payload.Format),
- Password: payload.Password,
+ Format: v1pb.ExportFormat(task.Payload.GetFormat()),
+ Password: task.Payload.GetPassword(),
}
bytes, _, exportErr := apiv1.DoExport(ctx, exec.store, exec.dbFactory, exec.license, exportRequest, issue.Creator /* user */, instance, database, nil, exec.schemaSyncer)
if exportErr != nil {
@@ -86,7 +81,7 @@ func (exec *DataExportExecutor) RunOnce(ctx context.Context, _ context.Context,
exportArchive, err := exec.store.CreateExportArchive(ctx, &store.ExportArchiveMessage{
Bytes: bytes,
Payload: &storepb.ExportArchivePayload{
- FileFormat: payload.Format,
+ FileFormat: task.Payload.GetFormat(),
},
})
if err != nil {
diff --git a/backend/runner/taskrun/data_update_executor.go b/backend/runner/taskrun/data_update_executor.go
index 6b8238d7b9..935f7b1f2d 100644
--- a/backend/runner/taskrun/data_update_executor.go
+++ b/backend/runner/taskrun/data_update_executor.go
@@ -52,12 +52,7 @@ type DataUpdateExecutor struct {
// RunOnce will run the data update (DML) task executor once.
func (exec *DataUpdateExecutor) RunOnce(ctx context.Context, driverCtx context.Context, task *store.TaskMessage, taskRunUID int) (bool, *storepb.TaskRunResult, error) {
- payload := &storepb.TaskDatabaseUpdatePayload{}
- if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(task.Payload), payload); err != nil {
- return true, nil, errors.Wrap(err, "invalid database data update payload")
- }
-
- sheetID := int(payload.SheetId)
+ sheetID := int(task.Payload.GetSheetId())
statement, err := exec.store.GetSheetStatementByID(ctx, sheetID)
if err != nil {
return true, nil, err
@@ -87,7 +82,7 @@ func (exec *DataUpdateExecutor) RunOnce(ctx context.Context, driverCtx context.C
PriorBackupStart: &storepb.TaskRunLog_PriorBackupStart{},
})
- priorBackupDetail, backupErr := exec.backupData(ctx, driverCtx, statement, payload, task, issueN, instance, database)
+ priorBackupDetail, backupErr := exec.backupData(ctx, driverCtx, statement, task.Payload, task, issueN, instance, database)
if backupErr != nil {
exec.store.CreateTaskRunLogS(ctx, taskRunUID, time.Now(), exec.profile.DeployID, &storepb.TaskRunLog{
Type: storepb.TaskRunLog_PRIOR_BACKUP_END,
@@ -127,7 +122,7 @@ func (exec *DataUpdateExecutor) RunOnce(ctx context.Context, driverCtx context.C
},
})
}
- terminated, result, err := runMigration(ctx, driverCtx, exec.store, exec.dbFactory, exec.stateCfg, exec.schemaSyncer, exec.profile, task, taskRunUID, db.Data, statement, payload.SchemaVersion, &sheetID)
+ terminated, result, err := runMigration(ctx, driverCtx, exec.store, exec.dbFactory, exec.stateCfg, exec.schemaSyncer, exec.profile, task, taskRunUID, db.Data, statement, task.Payload.GetSchemaVersion(), &sheetID)
if result != nil {
// Save prior backup detail to task run result.
result.PriorBackupDetail = priorBackupDetail
@@ -157,13 +152,13 @@ func (exec *DataUpdateExecutor) backupData(
ctx context.Context,
driverCtx context.Context,
originStatement string,
- payload *storepb.TaskDatabaseUpdatePayload,
+ payload *storepb.TaskPayload,
task *store.TaskMessage,
issueN *store.IssueMessage,
instance *store.InstanceMessage,
database *store.DatabaseMessage,
) (*storepb.PriorBackupDetail, error) {
- if payload.PreUpdateBackupDetail == nil || payload.PreUpdateBackupDetail.Database == "" {
+ if payload.GetPreUpdateBackupDetail().GetDatabase() == "" {
return nil, nil
}
diff --git a/backend/runner/taskrun/database_create_executor.go b/backend/runner/taskrun/database_create_executor.go
index 9a622c0e00..1bdf53637f 100644
--- a/backend/runner/taskrun/database_create_executor.go
+++ b/backend/runner/taskrun/database_create_executor.go
@@ -8,7 +8,6 @@ import (
"github.com/pkg/errors"
- "github.com/bytebase/bytebase/backend/common"
"github.com/bytebase/bytebase/backend/common/log"
"github.com/bytebase/bytebase/backend/component/config"
"github.com/bytebase/bytebase/backend/component/dbfactory"
@@ -48,11 +47,7 @@ var cannotCreateDatabase = map[storepb.Engine]bool{
// RunOnce will run the database create task executor once.
func (exec *DatabaseCreateExecutor) RunOnce(ctx context.Context, driverCtx context.Context, task *store.TaskMessage, _ int) (terminated bool, result *storepb.TaskRunResult, err error) {
- payload := &storepb.TaskDatabaseCreatePayload{}
- if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(task.Payload), payload); err != nil {
- return true, nil, errors.Wrap(err, "invalid create database payload")
- }
- sheetID := int(payload.SheetId)
+ sheetID := int(task.Payload.GetSheetId())
statement, err := exec.store.GetSheetStatementByID(ctx, sheetID)
if err != nil {
return true, nil, errors.Wrapf(err, "failed to get sheet statement of sheet: %d", sheetID)
@@ -97,15 +92,15 @@ func (exec *DatabaseCreateExecutor) RunOnce(ctx context.Context, driverCtx conte
// Create database.
slog.Debug("Start creating database...",
slog.String("instance", instance.Metadata.GetTitle()),
- slog.String("database", payload.DatabaseName),
+ slog.String("database", task.Payload.GetDatabaseName()),
slog.String("statement", statement),
)
database, err := exec.store.UpsertDatabase(ctx, &store.DatabaseMessage{
ProjectID: pipeline.ProjectID,
InstanceID: instance.ResourceID,
- DatabaseName: payload.DatabaseName,
- EnvironmentID: payload.EnvironmentId,
+ DatabaseName: task.Payload.GetDatabaseName(),
+ EnvironmentID: task.Payload.GetEnvironmentId(),
Metadata: &storepb.DatabaseMetadata{},
})
if err != nil {
@@ -142,6 +137,6 @@ func (exec *DatabaseCreateExecutor) RunOnce(ctx context.Context, driverCtx conte
}
return true, &storepb.TaskRunResult{
- Detail: fmt.Sprintf("Created database %q", payload.DatabaseName),
+ Detail: fmt.Sprintf("Created database %q", task.Payload.GetDatabaseName()),
}, nil
}
diff --git a/backend/runner/taskrun/executor.go b/backend/runner/taskrun/executor.go
index 0b92eb1c48..2b086030ce 100644
--- a/backend/runner/taskrun/executor.go
+++ b/backend/runner/taskrun/executor.go
@@ -139,12 +139,7 @@ func getMigrationInfo(ctx context.Context, stores *store.Store, profile *config.
}
if task.Type.ChangeDatabasePayload() {
- var p storepb.TaskDatabaseUpdatePayload
- if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(task.Payload), &p); err != nil {
- return nil, errors.Wrapf(err, "failed to unmarshal task payload")
- }
-
- if f := p.TaskReleaseSource.GetFile(); f != "" {
+ if f := task.Payload.GetTaskReleaseSource().GetFile(); f != "" {
project, release, _, err := common.GetProjectReleaseUIDFile(f)
if err != nil {
return nil, errors.Wrapf(err, "failed to parse file %s", f)
@@ -530,8 +525,6 @@ func convertTaskType(t api.TaskType) storepb.ChangelogPayload_Type {
return storepb.ChangelogPayload_BASELINE
case api.TaskDatabaseSchemaUpdate:
return storepb.ChangelogPayload_MIGRATE
- case api.TaskDatabaseSchemaUpdateSDL:
- return storepb.ChangelogPayload_MIGRATE_SDL
case api.TaskDatabaseSchemaUpdateGhost:
return storepb.ChangelogPayload_MIGRATE_GHOST
diff --git a/backend/runner/taskrun/schedulerv2.go b/backend/runner/taskrun/schedulerv2.go
index 3736326fd7..87c40be673 100644
--- a/backend/runner/taskrun/schedulerv2.go
+++ b/backend/runner/taskrun/schedulerv2.go
@@ -2,7 +2,6 @@ package taskrun
import (
"context"
- "encoding/json"
"fmt"
"log/slog"
"sync"
@@ -211,15 +210,11 @@ func (s *SchedulerV2) scheduleAutoRolloutTask(ctx context.Context, rolloutPolicy
return nil
}
- sheetUID, err := api.GetSheetUIDFromTaskPayload(task.Payload)
- if err != nil {
- return errors.Wrapf(err, "failed to get sheet uid")
- }
-
+ sheetUID := int(task.Payload.GetSheetId())
create := &store.TaskRunMessage{
CreatorID: api.SystemBotID,
TaskUID: task.ID,
- SheetUID: sheetUID,
+ SheetUID: &sheetUID,
}
if err := s.store.CreatePendingTaskRuns(ctx, create); err != nil {
@@ -283,17 +278,12 @@ func (s *SchedulerV2) schedulePendingTaskRun(ctx context.Context, taskRun *store
return true, nil
}
- var version struct {
- Version string `json:"schemaVersion"`
- }
- if err := json.Unmarshal([]byte(task.Payload), &version); err != nil {
- return false, errors.Wrapf(err, "failed to unmarshal task payload")
- }
- if version.Version == "" {
+ schemaVersion := task.Payload.GetSchemaVersion()
+ if schemaVersion == "" {
return true, nil
}
- taskIDs, err := s.store.FindBlockingTasksByVersion(ctx, task.InstanceID, *task.DatabaseName, version.Version)
+ taskIDs, err := s.store.FindBlockingTasksByVersion(ctx, task.InstanceID, *task.DatabaseName, schemaVersion)
if err != nil {
return false, errors.Wrapf(err, "failed to find blocking versioned tasks")
}
@@ -863,10 +853,7 @@ func (s *SchedulerV2) createActivityForTaskRunStatusUpdate(ctx context.Context,
func tasksSkippedOrDone(tasks []*store.TaskMessage) (bool, error) {
for _, task := range tasks {
- skipped, err := utils.GetTaskSkipped(task)
- if err != nil {
- return false, err
- }
+ skipped := task.Payload.GetSkipped()
done := task.LatestTaskRunStatus == api.TaskRunDone
if !skipped && !done {
return false, nil
diff --git a/backend/runner/taskrun/schema_baseline_executor.go b/backend/runner/taskrun/schema_baseline_executor.go
index 36b3a6f769..0d29aece3c 100644
--- a/backend/runner/taskrun/schema_baseline_executor.go
+++ b/backend/runner/taskrun/schema_baseline_executor.go
@@ -4,9 +4,6 @@ import (
"context"
"log/slog"
- "github.com/pkg/errors"
-
- "github.com/bytebase/bytebase/backend/common"
"github.com/bytebase/bytebase/backend/common/log"
"github.com/bytebase/bytebase/backend/component/config"
"github.com/bytebase/bytebase/backend/component/dbfactory"
@@ -42,11 +39,6 @@ type SchemaBaselineExecutor struct {
// RunOnce will run the schema update (DDL) task executor once.
func (exec *SchemaBaselineExecutor) RunOnce(ctx context.Context, driverCtx context.Context, task *store.TaskMessage, taskRunUID int) (bool, *storepb.TaskRunResult, error) {
- payload := &storepb.TaskDatabaseUpdatePayload{}
- if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(task.Payload), payload); err != nil {
- return true, nil, errors.Wrap(err, "invalid database schema baseline payload")
- }
-
instance, err := exec.store.GetInstanceV2(ctx, &store.FindInstanceMessage{ResourceID: &task.InstanceID})
if err != nil {
return true, nil, err
@@ -56,7 +48,7 @@ func (exec *SchemaBaselineExecutor) RunOnce(ctx context.Context, driverCtx conte
return true, nil, err
}
- terminated, result, err := runMigration(ctx, driverCtx, exec.store, exec.dbFactory, exec.stateCfg, exec.schemaSyncer, exec.profile, task, taskRunUID, db.Baseline, "" /* statement */, payload.SchemaVersion, nil /* sheetID */)
+ terminated, result, err := runMigration(ctx, driverCtx, exec.store, exec.dbFactory, exec.stateCfg, exec.schemaSyncer, exec.profile, task, taskRunUID, db.Baseline, "" /* statement */, task.Payload.GetSchemaVersion(), nil /* sheetID */)
if err := exec.schemaSyncer.SyncDatabaseSchema(ctx, database); err != nil {
slog.Error("failed to sync database schema",
slog.String("instanceName", instance.ResourceID),
diff --git a/backend/runner/taskrun/schema_update_executor.go b/backend/runner/taskrun/schema_update_executor.go
index 3db5d18da5..04141d103f 100644
--- a/backend/runner/taskrun/schema_update_executor.go
+++ b/backend/runner/taskrun/schema_update_executor.go
@@ -5,9 +5,6 @@ import (
"log/slog"
"time"
- "github.com/pkg/errors"
-
- "github.com/bytebase/bytebase/backend/common"
"github.com/bytebase/bytebase/backend/common/log"
"github.com/bytebase/bytebase/backend/component/config"
"github.com/bytebase/bytebase/backend/component/dbfactory"
@@ -43,11 +40,6 @@ type SchemaUpdateExecutor struct {
// RunOnce will run the schema update (DDL) task executor once.
func (exec *SchemaUpdateExecutor) RunOnce(ctx context.Context, driverCtx context.Context, task *store.TaskMessage, taskRunUID int) (bool, *storepb.TaskRunResult, error) {
- payload := &storepb.TaskDatabaseUpdatePayload{}
- if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(task.Payload), payload); err != nil {
- return true, nil, errors.Wrap(err, "invalid database schema update payload")
- }
-
instance, err := exec.store.GetInstanceV2(ctx, &store.FindInstanceMessage{ResourceID: &task.InstanceID})
if err != nil {
return true, nil, err
@@ -57,13 +49,13 @@ func (exec *SchemaUpdateExecutor) RunOnce(ctx context.Context, driverCtx context
return true, nil, err
}
- sheetID := int(payload.SheetId)
+ sheetID := int(task.Payload.GetSheetId())
statement, err := exec.store.GetSheetStatementByID(ctx, sheetID)
if err != nil {
return true, nil, err
}
- terminated, result, err := runMigration(ctx, driverCtx, exec.store, exec.dbFactory, exec.stateCfg, exec.schemaSyncer, exec.profile, task, taskRunUID, db.Migrate, statement, payload.SchemaVersion, &sheetID)
+ terminated, result, err := runMigration(ctx, driverCtx, exec.store, exec.dbFactory, exec.stateCfg, exec.schemaSyncer, exec.profile, task, taskRunUID, db.Migrate, statement, task.Payload.GetSchemaVersion(), &sheetID)
// sync database schema anyways
exec.store.CreateTaskRunLogS(ctx, taskRunUID, time.Now(), exec.profile.DeployID, &storepb.TaskRunLog{
Type: storepb.TaskRunLog_DATABASE_SYNC_START,
diff --git a/backend/runner/taskrun/schema_update_ghost_executor.go b/backend/runner/taskrun/schema_update_ghost_executor.go
index 2d6153ec06..0cd83ddc2d 100644
--- a/backend/runner/taskrun/schema_update_ghost_executor.go
+++ b/backend/runner/taskrun/schema_update_ghost_executor.go
@@ -50,16 +50,12 @@ type SchemaUpdateGhostExecutor struct {
}
func (exec *SchemaUpdateGhostExecutor) RunOnce(ctx context.Context, driverCtx context.Context, task *store.TaskMessage, taskRunUID int) (bool, *storepb.TaskRunResult, error) {
- payload := &storepb.TaskDatabaseUpdatePayload{}
- if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(task.Payload), payload); err != nil {
- return true, nil, errors.Wrap(err, "invalid database schema update gh-ost sync payload")
- }
- sheetID := int(payload.SheetId)
- statement, err := exec.s.GetSheetStatementByID(ctx, int(payload.SheetId))
+ sheetID := int(task.Payload.GetSheetId())
+ statement, err := exec.s.GetSheetStatementByID(ctx, sheetID)
if err != nil {
return true, nil, err
}
- flags := payload.Flags
+ flags := task.Payload.GetFlags()
instance, err := exec.s.GetInstanceV2(ctx, &store.FindInstanceMessage{ResourceID: &task.InstanceID})
if err != nil {
@@ -153,7 +149,7 @@ func (exec *SchemaUpdateGhostExecutor) RunOnce(ctx context.Context, driverCtx co
}
}
- terminated, result, err := runMigrationWithFunc(ctx, driverCtx, exec.s, exec.dbFactory, exec.stateCfg, exec.schemaSyncer, exec.profile, task, taskRunUID, db.Migrate, statement, payload.SchemaVersion, &sheetID, execFunc)
+ terminated, result, err := runMigrationWithFunc(ctx, driverCtx, exec.s, exec.dbFactory, exec.stateCfg, exec.schemaSyncer, exec.profile, task, taskRunUID, db.Migrate, statement, task.Payload.GetSchemaVersion(), &sheetID, execFunc)
// sync database schema anyways
exec.s.CreateTaskRunLogS(ctx, taskRunUID, time.Now(), exec.profile.DeployID, &storepb.TaskRunLog{
Type: storepb.TaskRunLog_DATABASE_SYNC_START,
diff --git a/backend/runner/taskrun/schema_update_sdl_executor.go b/backend/runner/taskrun/schema_update_sdl_executor.go
deleted file mode 100644
index 401c1e55a4..0000000000
--- a/backend/runner/taskrun/schema_update_sdl_executor.go
+++ /dev/null
@@ -1,86 +0,0 @@
-package taskrun
-
-import (
- "context"
- "log/slog"
-
- "github.com/pkg/errors"
-
- "github.com/bytebase/bytebase/backend/common"
- "github.com/bytebase/bytebase/backend/common/log"
- "github.com/bytebase/bytebase/backend/component/config"
- "github.com/bytebase/bytebase/backend/component/dbfactory"
- "github.com/bytebase/bytebase/backend/component/state"
- enterprise "github.com/bytebase/bytebase/backend/enterprise/api"
- "github.com/bytebase/bytebase/backend/plugin/db"
- "github.com/bytebase/bytebase/backend/runner/schemasync"
- "github.com/bytebase/bytebase/backend/runner/utils"
- "github.com/bytebase/bytebase/backend/store"
- backendutils "github.com/bytebase/bytebase/backend/utils"
- storepb "github.com/bytebase/bytebase/proto/generated-go/store"
-)
-
-// NewSchemaUpdateSDLExecutor creates a schema update (SDL) task executor.
-func NewSchemaUpdateSDLExecutor(store *store.Store, dbFactory *dbfactory.DBFactory, license enterprise.LicenseService, stateCfg *state.State, schemaSyncer *schemasync.Syncer, profile *config.Profile) Executor {
- return &SchemaUpdateSDLExecutor{
- store: store,
- dbFactory: dbFactory,
- license: license,
- stateCfg: stateCfg,
- schemaSyncer: schemaSyncer,
- profile: profile,
- }
-}
-
-// SchemaUpdateSDLExecutor is the schema update (SDL) task executor.
-type SchemaUpdateSDLExecutor struct {
- store *store.Store
- dbFactory *dbfactory.DBFactory
- license enterprise.LicenseService
- stateCfg *state.State
- schemaSyncer *schemasync.Syncer
- profile *config.Profile
-}
-
-// RunOnce will run the schema update (SDL) task executor once.
-func (exec *SchemaUpdateSDLExecutor) RunOnce(ctx context.Context, driverCtx context.Context, task *store.TaskMessage, taskRunUID int) (bool, *storepb.TaskRunResult, error) {
- payload := &storepb.TaskDatabaseUpdatePayload{}
- if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(task.Payload), payload); err != nil {
- return true, nil, errors.Wrap(err, "invalid database schema update payload")
- }
-
- sheetID := int(payload.SheetId)
- statement, err := exec.store.GetSheetStatementByID(ctx, sheetID)
- if err != nil {
- return true, nil, err
- }
-
- instance, err := exec.store.GetInstanceV2(ctx, &store.FindInstanceMessage{ResourceID: &task.InstanceID})
- if err != nil {
- return true, nil, err
- }
- database, err := exec.store.GetDatabaseV2(ctx, &store.FindDatabaseMessage{InstanceID: &task.InstanceID, DatabaseName: task.DatabaseName})
- if err != nil {
- return true, nil, err
- }
-
- materials := backendutils.GetSecretMapFromDatabaseMessage(database)
- // To avoid leaking the rendered statement, the error message should use the original statement and not the rendered statement.
- renderedStatement := backendutils.RenderStatement(statement, materials)
-
- ddl, err := utils.ComputeDatabaseSchemaDiff(ctx, instance, database, exec.dbFactory, renderedStatement)
- if err != nil {
- return true, nil, errors.Wrap(err, "invalid database schema diff")
- }
- terminated, result, err := runMigration(ctx, driverCtx, exec.store, exec.dbFactory, exec.stateCfg, exec.schemaSyncer, exec.profile, task, taskRunUID, db.MigrateSDL, ddl, payload.SchemaVersion, &sheetID)
-
- if err := exec.schemaSyncer.SyncDatabaseSchema(ctx, database); err != nil {
- slog.Error("failed to sync database schema",
- slog.String("instanceName", instance.ResourceID),
- slog.String("databaseName", database.DatabaseName),
- log.BBError(err),
- )
- }
-
- return terminated, result, err
-}
diff --git a/backend/server/server.go b/backend/server/server.go
index c6467035c8..51f431a4b7 100644
--- a/backend/server/server.go
+++ b/backend/server/server.go
@@ -281,7 +281,6 @@ func NewServer(ctx context.Context, profile *config.Profile) (*Server, error) {
s.taskSchedulerV2.Register(api.TaskDatabaseCreate, taskrun.NewDatabaseCreateExecutor(storeInstance, s.dbFactory, s.schemaSyncer, s.stateCfg, profile))
s.taskSchedulerV2.Register(api.TaskDatabaseSchemaBaseline, taskrun.NewSchemaBaselineExecutor(storeInstance, s.dbFactory, s.licenseService, s.stateCfg, s.schemaSyncer, profile))
s.taskSchedulerV2.Register(api.TaskDatabaseSchemaUpdate, taskrun.NewSchemaUpdateExecutor(storeInstance, s.dbFactory, s.licenseService, s.stateCfg, s.schemaSyncer, profile))
- s.taskSchedulerV2.Register(api.TaskDatabaseSchemaUpdateSDL, taskrun.NewSchemaUpdateSDLExecutor(storeInstance, s.dbFactory, s.licenseService, s.stateCfg, s.schemaSyncer, profile))
s.taskSchedulerV2.Register(api.TaskDatabaseDataUpdate, taskrun.NewDataUpdateExecutor(storeInstance, s.dbFactory, s.licenseService, s.stateCfg, s.schemaSyncer, profile))
s.taskSchedulerV2.Register(api.TaskDatabaseDataExport, taskrun.NewDataExportExecutor(storeInstance, s.dbFactory, s.licenseService, s.stateCfg, s.schemaSyncer, profile))
s.taskSchedulerV2.Register(api.TaskDatabaseSchemaUpdateGhost, taskrun.NewSchemaUpdateGhostExecutor(storeInstance, s.secret, s.dbFactory, s.licenseService, s.stateCfg, s.schemaSyncer, s.profile))
diff --git a/backend/store/pipeline.go b/backend/store/pipeline.go
index a881a844c4..0ffa1202f8 100644
--- a/backend/store/pipeline.go
+++ b/backend/store/pipeline.go
@@ -3,7 +3,6 @@ package store
import (
"context"
"database/sql"
- "encoding/json"
"fmt"
"strings"
"time"
@@ -92,15 +91,9 @@ func (s *Store) CreatePipelineAIO(ctx context.Context, planUID int64, pipeline *
createdTasks := map[taskKey]struct{}{}
for _, task := range tasks {
- var payloadSheetUID struct {
- SheetUID int `json:"sheetId"`
- }
- if err := json.Unmarshal([]byte(task.Payload), &payloadSheetUID); err != nil {
- return 0, errors.Wrapf(err, "failed to unmarshal task payload")
- }
k := taskKey{
instance: task.InstanceID,
- sheet: payloadSheetUID.SheetUID,
+ sheet: int(task.Payload.GetSheetId()),
}
if task.DatabaseName != nil {
k.database = *task.DatabaseName
@@ -111,15 +104,9 @@ func (s *Store) CreatePipelineAIO(ctx context.Context, planUID int64, pipeline *
var taskCreateList []*TaskMessage
for _, taskCreate := range stage.TaskList {
- var payloadSheetUID struct {
- SheetUID int `json:"sheetId"`
- }
- if err := json.Unmarshal([]byte(taskCreate.Payload), &payloadSheetUID); err != nil {
- return 0, errors.Wrapf(err, "failed to unmarshal task payload")
- }
k := taskKey{
instance: taskCreate.InstanceID,
- sheet: payloadSheetUID.SheetUID,
+ sheet: int(taskCreate.Payload.GetSheetId()),
}
if taskCreate.DatabaseName != nil {
k.database = *taskCreate.DatabaseName
diff --git a/backend/store/task.go b/backend/store/task.go
index ad11259c77..5f21887d58 100644
--- a/backend/store/task.go
+++ b/backend/store/task.go
@@ -11,6 +11,7 @@ import (
"time"
"github.com/pkg/errors"
+ "google.golang.org/protobuf/encoding/protojson"
"github.com/bytebase/bytebase/backend/common"
api "github.com/bytebase/bytebase/backend/legacyapi"
@@ -31,7 +32,7 @@ type TaskMessage struct {
// Domain specific fields
Type api.TaskType
- Payload string
+ Payload *storepb.TaskPayload
EarliestAllowedAt *time.Time
LatestTaskRunStatus api.TaskRunStatus
@@ -50,9 +51,6 @@ type TaskFind struct {
// Domain specific fields
TypeList *[]api.TaskType
- // Payload contains JSONB expressions
- // Ref: https://www.postgresql.org/docs/current/functions-json.html
- Payload string
LatestTaskRunStatusList *[]api.TaskRunStatus
}
@@ -169,19 +167,23 @@ func (*Store) createTasks(ctx context.Context, tx *Tx, creates ...*TaskMessage)
instances []string
databases []*string
types []string
- payloads []string
+ payloads [][]byte
earliestAllowedAts []time.Time
)
for _, create := range creates {
- if create.Payload == "" {
- create.Payload = "{}"
+ if create.Payload == nil {
+ create.Payload = &storepb.TaskPayload{}
+ }
+ payload, err := protojson.Marshal(create.Payload)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to marshal payload")
}
pipelineIDs = append(pipelineIDs, create.PipelineID)
stageIDs = append(stageIDs, create.StageID)
instances = append(instances, create.InstanceID)
databases = append(databases, create.DatabaseName)
types = append(types, string(create.Type))
- payloads = append(payloads, create.Payload)
+ payloads = append(payloads, payload)
if create.EarliestAllowedAt == nil {
earliestAllowedAts = append(earliestAllowedAts, time.Time{})
} else {
@@ -206,6 +208,7 @@ func (*Store) createTasks(ctx context.Context, tx *Tx, creates ...*TaskMessage)
for rows.Next() {
task := &TaskMessage{}
var earliestAllowedAt sql.NullTime
+ var payload []byte
if err := rows.Scan(
&task.ID,
&task.PipelineID,
@@ -213,7 +216,7 @@ func (*Store) createTasks(ctx context.Context, tx *Tx, creates ...*TaskMessage)
&task.InstanceID,
&task.DatabaseName,
&task.Type,
- &task.Payload,
+ &payload,
&earliestAllowedAt,
); err != nil {
return nil, errors.Wrapf(err, "failed to scan rows")
@@ -221,6 +224,11 @@ func (*Store) createTasks(ctx context.Context, tx *Tx, creates ...*TaskMessage)
if earliestAllowedAt.Valid {
task.EarliestAllowedAt = &earliestAllowedAt.Time
}
+ taskPayload := &storepb.TaskPayload{}
+ if err := common.ProtojsonUnmarshaler.Unmarshal(payload, taskPayload); err != nil {
+ return nil, errors.Wrap(err, "failed to unmarshal plan config")
+ }
+ task.Payload = taskPayload
tasks = append(tasks, task)
}
if err := rows.Err(); err != nil {
@@ -262,9 +270,6 @@ func (*Store) listTasksTx(ctx context.Context, tx *Tx, find *TaskFind) ([]*TaskM
}
where = append(where, fmt.Sprintf("task.type in (%s)", strings.Join(list, ",")))
}
- if v := find.Payload; v != "" {
- where = append(where, v)
- }
args = append(args, api.TaskRunNotStarted)
rows, err := tx.QueryContext(ctx, fmt.Sprintf(`
@@ -303,6 +308,7 @@ func (*Store) listTasksTx(ctx context.Context, tx *Tx, find *TaskFind) ([]*TaskM
for rows.Next() {
task := &TaskMessage{}
var earliestAllowedAt sql.NullTime
+ var payload []byte
if err := rows.Scan(
&task.ID,
&task.PipelineID,
@@ -311,7 +317,7 @@ func (*Store) listTasksTx(ctx context.Context, tx *Tx, find *TaskFind) ([]*TaskM
&task.DatabaseName,
&task.LatestTaskRunStatus,
&task.Type,
- &task.Payload,
+ &payload,
&earliestAllowedAt,
); err != nil {
return nil, err
@@ -319,6 +325,11 @@ func (*Store) listTasksTx(ctx context.Context, tx *Tx, find *TaskFind) ([]*TaskM
if earliestAllowedAt.Valid {
task.EarliestAllowedAt = &earliestAllowedAt.Time
}
+ taskPayload := &storepb.TaskPayload{}
+ if err := common.ProtojsonUnmarshaler.Unmarshal(payload, taskPayload); err != nil {
+ return nil, errors.Wrap(err, "failed to unmarshal plan config")
+ }
+ task.Payload = taskPayload
tasks = append(tasks, task)
}
if err := rows.Err(); err != nil {
@@ -403,6 +414,7 @@ func (s *Store) UpdateTaskV2(ctx context.Context, patch *TaskPatch) (*TaskMessag
task := &TaskMessage{}
var earliestAllowedAt sql.NullTime
+ var payload []byte
if err := tx.QueryRowContext(ctx, fmt.Sprintf(`
UPDATE task
SET `+strings.Join(set, ", ")+`
@@ -429,6 +441,11 @@ func (s *Store) UpdateTaskV2(ctx context.Context, patch *TaskPatch) (*TaskMessag
if earliestAllowedAt.Valid {
task.EarliestAllowedAt = &earliestAllowedAt.Time
}
+ taskPayload := &storepb.TaskPayload{}
+ if err := common.ProtojsonUnmarshaler.Unmarshal(payload, taskPayload); err != nil {
+ return nil, errors.Wrap(err, "failed to unmarshal plan config")
+ }
+ task.Payload = taskPayload
if err := tx.Commit(); err != nil {
return nil, err
}
diff --git a/backend/utils/database_group.go b/backend/utils/database_group.go
deleted file mode 100644
index 9ea550d814..0000000000
--- a/backend/utils/database_group.go
+++ /dev/null
@@ -1,30 +0,0 @@
-package utils
-
-import (
- "github.com/pkg/errors"
-
- storepb "github.com/bytebase/bytebase/proto/generated-go/store"
-)
-
-// ConvertDatabaseToParserEngineType converts a database type to a parser engine type.
-func ConvertDatabaseToParserEngineType(engine storepb.Engine) (storepb.Engine, error) {
- switch engine {
- case storepb.Engine_ORACLE, storepb.Engine_OCEANBASE_ORACLE:
- return storepb.Engine_ORACLE, nil
- case storepb.Engine_MSSQL:
- return storepb.Engine_MSSQL, nil
- case storepb.Engine_POSTGRES:
- return storepb.Engine_POSTGRES, nil
- case storepb.Engine_REDSHIFT:
- return storepb.Engine_REDSHIFT, nil
- case storepb.Engine_MYSQL:
- return storepb.Engine_MYSQL, nil
- case storepb.Engine_TIDB:
- return storepb.Engine_TIDB, nil
- case storepb.Engine_MARIADB:
- return storepb.Engine_MARIADB, nil
- case storepb.Engine_OCEANBASE:
- return storepb.Engine_OCEANBASE, nil
- }
- return storepb.Engine_ENGINE_UNSPECIFIED, errors.Errorf("unsupported engine type %q", engine)
-}
diff --git a/backend/utils/utils.go b/backend/utils/utils.go
index c7105f49d7..7d1d3cb0eb 100644
--- a/backend/utils/utils.go
+++ b/backend/utils/utils.go
@@ -3,7 +3,6 @@ package utils
import (
"context"
- "encoding/json"
"fmt"
"io"
"reflect"
@@ -39,28 +38,6 @@ func DataSourceFromInstanceWithType(instance *store.InstanceMessage, dataSourceT
return nil
}
-// GetTaskSheetID gets the sheetID of a task.
-func GetTaskSheetID(taskPayload string) (int, error) {
- var taskSheetID struct {
- SheetID int `json:"sheetId"`
- }
- if err := json.Unmarshal([]byte(taskPayload), &taskSheetID); err != nil {
- return 0, err
- }
- return taskSheetID.SheetID, nil
-}
-
-// GetTaskSkipped gets skipped from a task.
-func GetTaskSkipped(task *store.TaskMessage) (bool, error) {
- var payload struct {
- Skipped bool `json:"skipped,omitempty"`
- }
- if err := json.Unmarshal([]byte(task.Payload), &payload); err != nil {
- return false, err
- }
- return payload.Skipped, nil
-}
-
// FindNextPendingStep finds the next pending step in the approval flow.
func FindNextPendingStep(template *storepb.ApprovalTemplate, approvers []*storepb.IssuePayloadApproval_Approver) *storepb.ApprovalStep {
// We can do the finding like this for now because we are presuming that
diff --git a/frontend/src/types/proto/google/protobuf/descriptor.ts b/frontend/src/types/proto/google/protobuf/descriptor.ts
index ae3f877dc7..2fdf22f5e2 100644
--- a/frontend/src/types/proto/google/protobuf/descriptor.ts
+++ b/frontend/src/types/proto/google/protobuf/descriptor.ts
@@ -36,7 +36,7 @@ export enum Edition {
EDITION_2024 = "EDITION_2024",
/**
* EDITION_1_TEST_ONLY - Placeholder editions for testing feature resolution. These should not be
- * used or relyed on outside of tests.
+ * used or relied on outside of tests.
*/
EDITION_1_TEST_ONLY = "EDITION_1_TEST_ONLY",
EDITION_2_TEST_ONLY = "EDITION_2_TEST_ONLY",
@@ -1093,12 +1093,13 @@ export interface MessageOptions {
export interface FieldOptions {
/**
+ * NOTE: ctype is deprecated. Use `features.(pb.cpp).string_type` instead.
* The ctype option instructs the C++ code generator to use a different
* representation of the field than it normally would. See the specific
* options below. This option is only implemented to support use of
* [ctype=CORD] and [ctype=STRING] (the default) on non-repeated fields of
- * type "bytes" in the open source release -- sorry, we'll try to include
- * other types in a future version!
+ * type "bytes" in the open source release.
+ * TODO: make ctype actually deprecated.
*/
ctype?:
| FieldOptions_CType
@@ -1314,11 +1315,7 @@ export function fieldOptions_JSTypeToNumber(object: FieldOptions_JSType): number
}
}
-/**
- * If set to RETENTION_SOURCE, the option will be omitted from the binary.
- * Note: as of January 2023, support for this is in progress and does not yet
- * have an effect (b/264593489).
- */
+/** If set to RETENTION_SOURCE, the option will be omitted from the binary. */
export enum FieldOptions_OptionRetention {
RETENTION_UNKNOWN = "RETENTION_UNKNOWN",
RETENTION_RUNTIME = "RETENTION_RUNTIME",
@@ -1375,8 +1372,7 @@ export function fieldOptions_OptionRetentionToNumber(object: FieldOptions_Option
/**
* This indicates the types of entities that the field may apply to when used
* as an option. If it is unset, then the field may be freely used as an
- * option on any kind of entity. Note: as of January 2023, support for this is
- * in progress and does not yet have an effect (b/264593489).
+ * option on any kind of entity.
*/
export enum FieldOptions_OptionTargetType {
TARGET_TYPE_UNKNOWN = "TARGET_TYPE_UNKNOWN",
diff --git a/frontend/src/types/proto/store/task.ts b/frontend/src/types/proto/store/task.ts
index 6c45df2b30..08634d673b 100644
--- a/frontend/src/types/proto/store/task.ts
+++ b/frontend/src/types/proto/store/task.ts
@@ -12,73 +12,65 @@ import { PreUpdateBackupDetail } from "./plan_check_run";
export const protobufPackage = "bytebase.store";
-/** TaskDatabaseCreatePayload is the task payload for creating databases. */
-export interface TaskDatabaseCreatePayload {
+export interface TaskPayload {
/** common fields */
skipped: boolean;
skippedReason: string;
specId: string;
+ sheetId: number;
+ /** Create database fields. */
+ environmentId: string;
databaseName: string;
tableName: string;
- sheetId: number;
characterSet: string;
collation: string;
- environmentId: string;
- labels: string;
-}
-
-/** TaskDatabaseUpdatePayload is the task payload for updating database (DDL & DML). */
-export interface TaskDatabaseUpdatePayload {
- /** common fields */
- skipped: boolean;
- skippedReason: string;
- specId: string;
+ /** Update database fields. */
schemaVersion: string;
- sheetId: number;
preUpdateBackupDetail:
| PreUpdateBackupDetail
| undefined;
- /** flags is used for ghost sync */
+ /** ghost flags. */
flags: { [key: string]: string };
- taskReleaseSource: TaskReleaseSource | undefined;
+ taskReleaseSource:
+ | TaskReleaseSource
+ | undefined;
+ /** Export data fields. */
+ password: string;
+ format: ExportFormat;
}
-export interface TaskDatabaseUpdatePayload_FlagsEntry {
+export interface TaskPayload_FlagsEntry {
key: string;
value: string;
}
-/** TaskDatabaseDataExportPayload is the task payload for database data export. */
-export interface TaskDatabaseDataExportPayload {
- /** common fields */
- specId: string;
- sheetId: number;
- password: string;
- format: ExportFormat;
-}
-
export interface TaskReleaseSource {
/** Format: projects/{project}/releases/{release}/files/{id} */
file: string;
}
-function createBaseTaskDatabaseCreatePayload(): TaskDatabaseCreatePayload {
+function createBaseTaskPayload(): TaskPayload {
return {
skipped: false,
skippedReason: "",
specId: "",
+ sheetId: 0,
+ environmentId: "",
databaseName: "",
tableName: "",
- sheetId: 0,
characterSet: "",
collation: "",
- environmentId: "",
- labels: "",
+ schemaVersion: "",
+ preUpdateBackupDetail: undefined,
+ flags: {},
+ taskReleaseSource: undefined,
+ password: "",
+ format: ExportFormat.FORMAT_UNSPECIFIED,
};
}
-export const TaskDatabaseCreatePayload: MessageFns<TaskDatabaseCreatePayload> = {
- encode(message: TaskDatabaseCreatePayload, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
+export const TaskPayload: MessageFns<TaskPayload> = {
+ encode(message: TaskPayload, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
if (message.skipped !== false) {
writer.uint32(8).bool(message.skipped);
}
@@ -88,14 +80,17 @@ export const TaskDatabaseCreatePayload: MessageFns<TaskDatabaseCreatePayload> =
if (message.specId !== "") {
writer.uint32(26).string(message.specId);
}
+ if (message.sheetId !== 0) {
+ writer.uint32(32).int32(message.sheetId);
+ }
+ if (message.environmentId !== "") {
+ writer.uint32(42).string(message.environmentId);
+ }
if (message.databaseName !== "") {
- writer.uint32(42).string(message.databaseName);
+ writer.uint32(50).string(message.databaseName);
}
if (message.tableName !== "") {
- writer.uint32(50).string(message.tableName);
- }
- if (message.sheetId !== 0) {
- writer.uint32(56).int32(message.sheetId);
+ writer.uint32(58).string(message.tableName);
}
if (message.characterSet !== "") {
writer.uint32(66).string(message.characterSet);
@@ -103,19 +98,31 @@ export const TaskDatabaseCreatePayload: MessageFns<TaskDatabaseCreatePayload> =
if (message.collation !== "") {
writer.uint32(74).string(message.collation);
}
- if (message.environmentId !== "") {
- writer.uint32(82).string(message.environmentId);
+ if (message.schemaVersion !== "") {
+ writer.uint32(82).string(message.schemaVersion);
+ }
+ if (message.preUpdateBackupDetail !== undefined) {
+ PreUpdateBackupDetail.encode(message.preUpdateBackupDetail, writer.uint32(90).fork()).join();
+ }
+ Object.entries(message.flags).forEach(([key, value]) => {
+ TaskPayload_FlagsEntry.encode({ key: key as any, value }, writer.uint32(98).fork()).join();
+ });
+ if (message.taskReleaseSource !== undefined) {
+ TaskReleaseSource.encode(message.taskReleaseSource, writer.uint32(106).fork()).join();
+ }
+ if (message.password !== "") {
+ writer.uint32(114).string(message.password);
}
- if (message.labels !== "") {
- writer.uint32(90).string(message.labels);
+ if (message.format !== ExportFormat.FORMAT_UNSPECIFIED) {
+ writer.uint32(120).int32(exportFormatToNumber(message.format));
}
return writer;
},
- decode(input: BinaryReader | Uint8Array, length?: number): TaskDatabaseCreatePayload {
+ decode(input: BinaryReader | Uint8Array, length?: number): TaskPayload {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
- const message = createBaseTaskDatabaseCreatePayload();
+ const message = createBaseTaskPayload();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
@@ -143,12 +150,20 @@ export const TaskDatabaseCreatePayload: MessageFns<TaskDatabaseCreatePayload> =
message.specId = reader.string();
continue;
}
+ case 4: {
+ if (tag !== 32) {
+ break;
+ }
+
+ message.sheetId = reader.int32();
+ continue;
+ }
case 5: {
if (tag !== 42) {
break;
}
- message.databaseName = reader.string();
+ message.environmentId = reader.string();
continue;
}
case 6: {
@@ -156,15 +171,15 @@ export const TaskDatabaseCreatePayload: MessageFns<TaskDatabaseCreatePayload> =
break;
}
- message.tableName = reader.string();
+ message.databaseName = reader.string();
continue;
}
case 7: {
- if (tag !== 56) {
+ if (tag !== 58) {
break;
}
- message.sheetId = reader.int32();
+ message.tableName = reader.string();
continue;
}
case 8: {
@@ -188,7 +203,7 @@ export const TaskDatabaseCreatePayload: MessageFns<TaskDatabaseCreatePayload> =
break;
}
- message.environmentId = reader.string();
+ message.schemaVersion = reader.string();
continue;
}
case 11: {
@@ -196,201 +211,42 @@ export const TaskDatabaseCreatePayload: MessageFns<TaskDatabaseCreatePayload> =
break;
}
- message.labels = reader.string();
- continue;
- }
- }
- if ((tag & 7) === 4 || tag === 0) {
- break;
- }
- reader.skip(tag & 7);
- }
- return message;
- },
-
- fromJSON(object: any): TaskDatabaseCreatePayload {
- return {
- skipped: isSet(object.skipped) ? globalThis.Boolean(object.skipped) : false,
- skippedReason: isSet(object.skippedReason) ? globalThis.String(object.skippedReason) : "",
- specId: isSet(object.specId) ? globalThis.String(object.specId) : "",
- databaseName: isSet(object.databaseName) ? globalThis.String(object.databaseName) : "",
- tableName: isSet(object.tableName) ? globalThis.String(object.tableName) : "",
- sheetId: isSet(object.sheetId) ? globalThis.Number(object.sheetId) : 0,
- characterSet: isSet(object.characterSet) ? globalThis.String(object.characterSet) : "",
- collation: isSet(object.collation) ? globalThis.String(object.collation) : "",
- environmentId: isSet(object.environmentId) ? globalThis.String(object.environmentId) : "",
- labels: isSet(object.labels) ? globalThis.String(object.labels) : "",
- };
- },
-
- toJSON(message: TaskDatabaseCreatePayload): unknown {
- const obj: any = {};
- if (message.skipped !== false) {
- obj.skipped = message.skipped;
- }
- if (message.skippedReason !== "") {
- obj.skippedReason = message.skippedReason;
- }
- if (message.specId !== "") {
- obj.specId = message.specId;
- }
- if (message.databaseName !== "") {
- obj.databaseName = message.databaseName;
- }
- if (message.tableName !== "") {
- obj.tableName = message.tableName;
- }
- if (message.sheetId !== 0) {
- obj.sheetId = Math.round(message.sheetId);
- }
- if (message.characterSet !== "") {
- obj.characterSet = message.characterSet;
- }
- if (message.collation !== "") {
- obj.collation = message.collation;
- }
- if (message.environmentId !== "") {
- obj.environmentId = message.environmentId;
- }
- if (message.labels !== "") {
- obj.labels = message.labels;
- }
- return obj;
- },
-
- create(base?: DeepPartial<TaskDatabaseCreatePayload>): TaskDatabaseCreatePayload {
- return TaskDatabaseCreatePayload.fromPartial(base ?? {});
- },
- fromPartial(object: DeepPartial<TaskDatabaseCreatePayload>): TaskDatabaseCreatePayload {
- const message = createBaseTaskDatabaseCreatePayload();
- message.skipped = object.skipped ?? false;
- message.skippedReason = object.skippedReason ?? "";
- message.specId = object.specId ?? "";
- message.databaseName = object.databaseName ?? "";
- message.tableName = object.tableName ?? "";
- message.sheetId = object.sheetId ?? 0;
- message.characterSet = object.characterSet ?? "";
- message.collation = object.collation ?? "";
- message.environmentId = object.environmentId ?? "";
- message.labels = object.labels ?? "";
- return message;
- },
-};
-
-function createBaseTaskDatabaseUpdatePayload(): TaskDatabaseUpdatePayload {
- return {
- skipped: false,
- skippedReason: "",
- specId: "",
- schemaVersion: "",
- sheetId: 0,
- preUpdateBackupDetail: undefined,
- flags: {},
- taskReleaseSource: undefined,
- };
-}
-
-export const TaskDatabaseUpdatePayload: MessageFns<TaskDatabaseUpdatePayload> = {
- encode(message: TaskDatabaseUpdatePayload, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
- if (message.skipped !== false) {
- writer.uint32(8).bool(message.skipped);
- }
- if (message.skippedReason !== "") {
- writer.uint32(18).string(message.skippedReason);
- }
- if (message.specId !== "") {
- writer.uint32(26).string(message.specId);
- }
- if (message.schemaVersion !== "") {
- writer.uint32(34).string(message.schemaVersion);
- }
- if (message.sheetId !== 0) {
- writer.uint32(40).int32(message.sheetId);
- }
- if (message.preUpdateBackupDetail !== undefined) {
- PreUpdateBackupDetail.encode(message.preUpdateBackupDetail, writer.uint32(50).fork()).join();
- }
- Object.entries(message.flags).forEach(([key, value]) => {
- TaskDatabaseUpdatePayload_FlagsEntry.encode({ key: key as any, value }, writer.uint32(58).fork()).join();
- });
- if (message.taskReleaseSource !== undefined) {
- TaskReleaseSource.encode(message.taskReleaseSource, writer.uint32(66).fork()).join();
- }
- return writer;
- },
-
- decode(input: BinaryReader | Uint8Array, length?: number): TaskDatabaseUpdatePayload {
- const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
- let end = length === undefined ? reader.len : reader.pos + length;
- const message = createBaseTaskDatabaseUpdatePayload();
- while (reader.pos < end) {
- const tag = reader.uint32();
- switch (tag >>> 3) {
- case 1: {
- if (tag !== 8) {
- break;
- }
-
- message.skipped = reader.bool();
- continue;
- }
- case 2: {
- if (tag !== 18) {
- break;
- }
-
- message.skippedReason = reader.string();
- continue;
- }
- case 3: {
- if (tag !== 26) {
- break;
- }
-
- message.specId = reader.string();
+ message.preUpdateBackupDetail = PreUpdateBackupDetail.decode(reader, reader.uint32());
continue;
}
- case 4: {
- if (tag !== 34) {
+ case 12: {
+ if (tag !== 98) {
break;
}
- message.schemaVersion = reader.string();
- continue;
- }
- case 5: {
- if (tag !== 40) {
- break;
+ const entry12 = TaskPayload_FlagsEntry.decode(reader, reader.uint32());
+ if (entry12.value !== undefined) {
+ message.flags[entry12.key] = entry12.value;
}
-
- message.sheetId = reader.int32();
continue;
}
- case 6: {
- if (tag !== 50) {
+ case 13: {
+ if (tag !== 106) {
break;
}
- message.preUpdateBackupDetail = PreUpdateBackupDetail.decode(reader, reader.uint32());
+ message.taskReleaseSource = TaskReleaseSource.decode(reader, reader.uint32());
continue;
}
- case 7: {
- if (tag !== 58) {
+ case 14: {
+ if (tag !== 114) {
break;
}
- const entry7 = TaskDatabaseUpdatePayload_FlagsEntry.decode(reader, reader.uint32());
- if (entry7.value !== undefined) {
- message.flags[entry7.key] = entry7.value;
- }
+ message.password = reader.string();
continue;
}
- case 8: {
- if (tag !== 66) {
+ case 15: {
+ if (tag !== 120) {
break;
}
- message.taskReleaseSource = TaskReleaseSource.decode(reader, reader.uint32());
+ message.format = exportFormatFromJSON(reader.int32());
continue;
}
}
@@ -402,13 +258,18 @@ export const TaskDatabaseUpdatePayload: MessageFns<TaskDatabaseUpdatePayload> =
return message;
},
- fromJSON(object: any): TaskDatabaseUpdatePayload {
+ fromJSON(object: any): TaskPayload {
return {
skipped: isSet(object.skipped) ? globalThis.Boolean(object.skipped) : false,
skippedReason: isSet(object.skippedReason) ? globalThis.String(object.skippedReason) : "",
specId: isSet(object.specId) ? globalThis.String(object.specId) : "",
- schemaVersion: isSet(object.schemaVersion) ? globalThis.String(object.schemaVersion) : "",
sheetId: isSet(object.sheetId) ? globalThis.Number(object.sheetId) : 0,
+ environmentId: isSet(object.environmentId) ? globalThis.String(object.environmentId) : "",
+ databaseName: isSet(object.databaseName) ? globalThis.String(object.databaseName) : "",
+ tableName: isSet(object.tableName) ? globalThis.String(object.tableName) : "",
+ characterSet: isSet(object.characterSet) ? globalThis.String(object.characterSet) : "",
+ collation: isSet(object.collation) ? globalThis.String(object.collation) : "",
+ schemaVersion: isSet(object.schemaVersion) ? globalThis.String(object.schemaVersion) : "",
preUpdateBackupDetail: isSet(object.preUpdateBackupDetail)
? PreUpdateBackupDetail.fromJSON(object.preUpdateBackupDetail)
: undefined,
@@ -421,10 +282,12 @@ export const TaskDatabaseUpdatePayload: MessageFns<TaskDatabaseUpdatePayload> =
taskReleaseSource: isSet(object.taskReleaseSource)
? TaskReleaseSource.fromJSON(object.taskReleaseSource)
: undefined,
+ password: isSet(object.password) ? globalThis.String(object.password) : "",
+ format: isSet(object.format) ? exportFormatFromJSON(object.format) : ExportFormat.FORMAT_UNSPECIFIED,
};
},
- toJSON(message: TaskDatabaseUpdatePayload): unknown {
+ toJSON(message: TaskPayload): unknown {
const obj: any = {};
if (message.skipped !== false) {
obj.skipped = message.skipped;
@@ -435,12 +298,27 @@ export const TaskDatabaseUpdatePayload: MessageFns<TaskDatabaseUpdatePayload> =
if (message.specId !== "") {
obj.specId = message.specId;
}
- if (message.schemaVersion !== "") {
- obj.schemaVersion = message.schemaVersion;
- }
if (message.sheetId !== 0) {
obj.sheetId = Math.round(message.sheetId);
}
+ if (message.environmentId !== "") {
+ obj.environmentId = message.environmentId;
+ }
+ if (message.databaseName !== "") {
+ obj.databaseName = message.databaseName;
+ }
+ if (message.tableName !== "") {
+ obj.tableName = message.tableName;
+ }
+ if (message.characterSet !== "") {
+ obj.characterSet = message.characterSet;
+ }
+ if (message.collation !== "") {
+ obj.collation = message.collation;
+ }
+ if (message.schemaVersion !== "") {
+ obj.schemaVersion = message.schemaVersion;
+ }
if (message.preUpdateBackupDetail !== undefined) {
obj.preUpdateBackupDetail = PreUpdateBackupDetail.toJSON(message.preUpdateBackupDetail);
}
@@ -456,19 +334,30 @@ export const TaskDatabaseUpdatePayload: MessageFns<TaskDatabaseUpdatePayload> =
if (message.taskReleaseSource !== undefined) {
obj.taskReleaseSource = TaskReleaseSource.toJSON(message.taskReleaseSource);
}
+ if (message.password !== "") {
+ obj.password = message.password;
+ }
+ if (message.format !== ExportFormat.FORMAT_UNSPECIFIED) {
+ obj.format = exportFormatToJSON(message.format);
+ }
return obj;
},
- create(base?: DeepPartial<TaskDatabaseUpdatePayload>): TaskDatabaseUpdatePayload {
- return TaskDatabaseUpdatePayload.fromPartial(base ?? {});
+ create(base?: DeepPartial<TaskPayload>): TaskPayload {
+ return TaskPayload.fromPartial(base ?? {});
},
- fromPartial(object: DeepPartial<TaskDatabaseUpdatePayload>): TaskDatabaseUpdatePayload {
- const message = createBaseTaskDatabaseUpdatePayload();
+ fromPartial(object: DeepPartial<TaskPayload>): TaskPayload {
+ const message = createBaseTaskPayload();
message.skipped = object.skipped ?? false;
message.skippedReason = object.skippedReason ?? "";
message.specId = object.specId ?? "";
- message.schemaVersion = object.schemaVersion ?? "";
message.sheetId = object.sheetId ?? 0;
+ message.environmentId = object.environmentId ?? "";
+ message.databaseName = object.databaseName ?? "";
+ message.tableName = object.tableName ?? "";
+ message.characterSet = object.characterSet ?? "";
+ message.collation = object.collation ?? "";
+ message.schemaVersion = object.schemaVersion ?? "";
message.preUpdateBackupDetail =
(object.preUpdateBackupDetail !== undefined && object.preUpdateBackupDetail !== null)
? PreUpdateBackupDetail.fromPartial(object.preUpdateBackupDetail)
@@ -482,16 +371,18 @@ export const TaskDatabaseUpdatePayload: MessageFns<TaskDatabaseUpdatePayload> =
message.taskReleaseSource = (object.taskReleaseSource !== undefined && object.taskReleaseSource !== null)
? TaskReleaseSource.fromPartial(object.taskReleaseSource)
: undefined;
+ message.password = object.password ?? "";
+ message.format = object.format ?? ExportFormat.FORMAT_UNSPECIFIED;
return message;
},
};
-function createBaseTaskDatabaseUpdatePayload_FlagsEntry(): TaskDatabaseUpdatePayload_FlagsEntry {
+function createBaseTaskPayload_FlagsEntry(): TaskPayload_FlagsEntry {
return { key: "", value: "" };
}
-export const TaskDatabaseUpdatePayload_FlagsEntry: MessageFns<TaskDatabaseUpdatePayload_FlagsEntry> = {
- encode(message: TaskDatabaseUpdatePayload_FlagsEntry, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
+export const TaskPayload_FlagsEntry: MessageFns<TaskPayload_FlagsEntry> = {
+ encode(message: TaskPayload_FlagsEntry, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
if (message.key !== "") {
writer.uint32(10).string(message.key);
}
@@ -501,10 +392,10 @@ export const TaskDatabaseUpdatePayload_FlagsEntry: MessageFns<TaskDatabaseUpdate
return writer;
},
- decode(input: BinaryReader | Uint8Array, length?: number): TaskDatabaseUpdatePayload_FlagsEntry {
+ decode(input: BinaryReader | Uint8Array, length?: number): TaskPayload_FlagsEntry {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
- const message = createBaseTaskDatabaseUpdatePayload_FlagsEntry();
+ const message = createBaseTaskPayload_FlagsEntry();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
@@ -533,14 +424,14 @@ export const TaskDatabaseUpdatePayload_FlagsEntry: MessageFns<TaskDatabaseUpdate
return message;
},
- fromJSON(object: any): TaskDatabaseUpdatePayload_FlagsEntry {
+ fromJSON(object: any): TaskPayload_FlagsEntry {
return {
key: isSet(object.key) ? globalThis.String(object.key) : "",
value: isSet(object.value) ? globalThis.String(object.value) : "",
};
},
- toJSON(message: TaskDatabaseUpdatePayload_FlagsEntry): unknown {
+ toJSON(message: TaskPayload_FlagsEntry): unknown {
const obj: any = {};
if (message.key !== "") {
obj.key = message.key;
@@ -551,125 +442,17 @@ export const TaskDatabaseUpdatePayload_FlagsEntry: MessageFns<TaskDatabaseUpdate
return obj;
},
- create(base?: DeepPartial<TaskDatabaseUpdatePayload_FlagsEntry>): TaskDatabaseUpdatePayload_FlagsEntry {
- return TaskDatabaseUpdatePayload_FlagsEntry.fromPartial(base ?? {});
+ create(base?: DeepPartial<TaskPayload_FlagsEntry>): TaskPayload_FlagsEntry {
+ return TaskPayload_FlagsEntry.fromPartial(base ?? {});
},
- fromPartial(object: DeepPartial<TaskDatabaseUpdatePayload_FlagsEntry>): TaskDatabaseUpdatePayload_FlagsEntry {
- const message = createBaseTaskDatabaseUpdatePayload_FlagsEntry();
+ fromPartial(object: DeepPartial<TaskPayload_FlagsEntry>): TaskPayload_FlagsEntry {
+ const message = createBaseTaskPayload_FlagsEntry();
message.key = object.key ?? "";
message.value = object.value ?? "";
return message;
},
};
-function createBaseTaskDatabaseDataExportPayload(): TaskDatabaseDataExportPayload {
- return { specId: "", sheetId: 0, password: "", format: ExportFormat.FORMAT_UNSPECIFIED };
-}
-
-export const TaskDatabaseDataExportPayload: MessageFns<TaskDatabaseDataExportPayload> = {
- encode(message: TaskDatabaseDataExportPayload, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
- if (message.specId !== "") {
- writer.uint32(10).string(message.specId);
- }
- if (message.sheetId !== 0) {
- writer.uint32(16).int32(message.sheetId);
- }
- if (message.password !== "") {
- writer.uint32(26).string(message.password);
- }
- if (message.format !== ExportFormat.FORMAT_UNSPECIFIED) {
- writer.uint32(32).int32(exportFormatToNumber(message.format));
- }
- return writer;
- },
-
- decode(input: BinaryReader | Uint8Array, length?: number): TaskDatabaseDataExportPayload {
- const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
- let end = length === undefined ? reader.len : reader.pos + length;
- const message = createBaseTaskDatabaseDataExportPayload();
- while (reader.pos < end) {
- const tag = reader.uint32();
- switch (tag >>> 3) {
- case 1: {
- if (tag !== 10) {
- break;
- }
-
- message.specId = reader.string();
- continue;
- }
- case 2: {
- if (tag !== 16) {
- break;
- }
-
- message.sheetId = reader.int32();
- continue;
- }
- case 3: {
- if (tag !== 26) {
- break;
- }
-
- message.password = reader.string();
- continue;
- }
- case 4: {
- if (tag !== 32) {
- break;
- }
-
- message.format = exportFormatFromJSON(reader.int32());
- continue;
- }
- }
- if ((tag & 7) === 4 || tag === 0) {
- break;
- }
- reader.skip(tag & 7);
- }
- return message;
- },
-
- fromJSON(object: any): TaskDatabaseDataExportPayload {
- return {
- specId: isSet(object.specId) ? globalThis.String(object.specId) : "",
- sheetId: isSet(object.sheetId) ? globalThis.Number(object.sheetId) : 0,
- password: isSet(object.password) ? globalThis.String(object.password) : "",
- format: isSet(object.format) ? exportFormatFromJSON(object.format) : ExportFormat.FORMAT_UNSPECIFIED,
- };
- },
-
- toJSON(message: TaskDatabaseDataExportPayload): unknown {
- const obj: any = {};
- if (message.specId !== "") {
- obj.specId = message.specId;
- }
- if (message.sheetId !== 0) {
- obj.sheetId = Math.round(message.sheetId);
- }
- if (message.password !== "") {
- obj.password = message.password;
- }
- if (message.format !== ExportFormat.FORMAT_UNSPECIFIED) {
- obj.format = exportFormatToJSON(message.format);
- }
- return obj;
- },
-
- create(base?: DeepPartial<TaskDatabaseDataExportPayload>): TaskDatabaseDataExportPayload {
- return TaskDatabaseDataExportPayload.fromPartial(base ?? {});
- },
- fromPartial(object: DeepPartial<TaskDatabaseDataExportPayload>): TaskDatabaseDataExportPayload {
- const message = createBaseTaskDatabaseDataExportPayload();
- message.specId = object.specId ?? "";
- message.sheetId = object.sheetId ?? 0;
- message.password = object.password ?? "";
- message.format = object.format ?? ExportFormat.FORMAT_UNSPECIFIED;
- return message;
- },
-};
-
function createBaseTaskReleaseSource(): TaskReleaseSource {
return { file: "" };
}
diff --git a/proto/gen/grpc-doc/store/README.md b/proto/gen/grpc-doc/store/README.md
index 872de3d4bd..e8052e2434 100644
--- a/proto/gen/grpc-doc/store/README.md
+++ b/proto/gen/grpc-doc/store/README.md
@@ -310,10 +310,8 @@
- [SlowQueryStatisticsItem](#bytebase-store-SlowQueryStatisticsItem)
- [store/task.proto](#store_task-proto)
- - [TaskDatabaseCreatePayload](#bytebase-store-TaskDatabaseCreatePayload)
- - [TaskDatabaseDataExportPayload](#bytebase-store-TaskDatabaseDataExportPayload)
- - [TaskDatabaseUpdatePayload](#bytebase-store-TaskDatabaseUpdatePayload)
- - [TaskDatabaseUpdatePayload.FlagsEntry](#bytebase-store-TaskDatabaseUpdatePayload-FlagsEntry)
+ - [TaskPayload](#bytebase-store-TaskPayload)
+ - [TaskPayload.FlagsEntry](#bytebase-store-TaskPayload-FlagsEntry)
- [TaskReleaseSource](#bytebase-store-TaskReleaseSource)
- [store/task_run.proto](#store_task_run-proto)
@@ -4838,10 +4836,10 @@ SlowQueryStatisticsItem is the item of slow query statistics.
-<a name="bytebase-store-TaskDatabaseCreatePayload"></a>
+<a name="bytebase-store-TaskPayload"></a>
+
+### TaskPayload
-### TaskDatabaseCreatePayload
-TaskDatabaseCreatePayload is the task payload for creating databases.
| Field | Type | Label | Description |
@@ -4849,62 +4847,27 @@ TaskDatabaseCreatePayload is the task payload for creating databases.
| skipped | [bool](#bool) | | common fields |
| skipped_reason | [string](#string) | | |
| spec_id | [string](#string) | | |
+| sheet_id | [int32](#int32) | | |
+| environment_id | [string](#string) | | Create database fields. |
| database_name | [string](#string) | | |
| table_name | [string](#string) | | |
-| sheet_id | [int32](#int32) | | |
| character_set | [string](#string) | | |
| collation | [string](#string) | | |
-| environment_id | [string](#string) | | |
-| labels | [string](#string) | | |
-
-
-
-
-
-
-<a name="bytebase-store-TaskDatabaseDataExportPayload"></a>
-
-### TaskDatabaseDataExportPayload
-TaskDatabaseDataExportPayload is the task payload for database data export.
-
-
-| Field | Type | Label | Description |
-| ----- | ---- | ----- | ----------- |
-| spec_id | [string](#string) | | common fields |
-| sheet_id | [int32](#int32) | | |
-| password | [string](#string) | | |
-| format | [ExportFormat](#bytebase-store-ExportFormat) | | |
-
-
-
-
-
-
-<a name="bytebase-store-TaskDatabaseUpdatePayload"></a>
-
-### TaskDatabaseUpdatePayload
-TaskDatabaseUpdatePayload is the task payload for updating database (DDL &amp; DML).
-
-
-| Field | Type | Label | Description |
-| ----- | ---- | ----- | ----------- |
-| skipped | [bool](#bool) | | common fields |
-| skipped_reason | [string](#string) | | |
-| spec_id | [string](#string) | | |
-| schema_version | [string](#string) | | |
-| sheet_id | [int32](#int32) | | |
+| schema_version | [string](#string) | | Update database fields. |
| pre_update_backup_detail | [PreUpdateBackupDetail](#bytebase-store-PreUpdateBackupDetail) | | |
-| flags | [TaskDatabaseUpdatePayload.FlagsEntry](#bytebase-store-TaskDatabaseUpdatePayload-FlagsEntry) | repeated | flags is used for ghost sync |
+| flags | [TaskPayload.FlagsEntry](#bytebase-store-TaskPayload-FlagsEntry) | repeated | ghost flags. |
| task_release_source | [TaskReleaseSource](#bytebase-store-TaskReleaseSource) | | |
+| password | [string](#string) | | Export data fields. |
+| format | [ExportFormat](#bytebase-store-ExportFormat) | | |
-<a name="bytebase-store-TaskDatabaseUpdatePayload-FlagsEntry"></a>
+<a name="bytebase-store-TaskPayload-FlagsEntry"></a>
-### TaskDatabaseUpdatePayload.FlagsEntry
+### TaskPayload.FlagsEntry
diff --git a/proto/gen/grpc-doc/store/index.html b/proto/gen/grpc-doc/store/index.html
index 75b84ffa82..0e05fb9c1a 100644
--- a/proto/gen/grpc-doc/store/index.html
+++ b/proto/gen/grpc-doc/store/index.html
@@ -1439,19 +1439,11 @@
<ul>
<li>
- <a href="#bytebase.store.TaskDatabaseCreatePayload"><span class="badge">M</span>TaskDatabaseCreatePayload</a>
+ <a href="#bytebase.store.TaskPayload"><span class="badge">M</span>TaskPayload</a>
</li>
<li>
- <a href="#bytebase.store.TaskDatabaseDataExportPayload"><span class="badge">M</span>TaskDatabaseDataExportPayload</a>
- </li>
-
- <li>
- <a href="#bytebase.store.TaskDatabaseUpdatePayload"><span class="badge">M</span>TaskDatabaseUpdatePayload</a>
- </li>
-
- <li>
- <a href="#bytebase.store.TaskDatabaseUpdatePayload.FlagsEntry"><span class="badge">M</span>TaskDatabaseUpdatePayload.FlagsEntry</a>
+ <a href="#bytebase.store.TaskPayload.FlagsEntry"><span class="badge">M</span>TaskPayload.FlagsEntry</a>
</li>
<li>
@@ -12182,8 +12174,8 @@ Default to this mode.</p></td>
<p></p>
- <h3 id="bytebase.store.TaskDatabaseCreatePayload">TaskDatabaseCreatePayload</h3>
- <p>TaskDatabaseCreatePayload is the task payload for creating databases.</p>
+ <h3 id="bytebase.store.TaskPayload">TaskPayload</h3>
+ <p></p>
<table class="field-table">
@@ -12213,20 +12205,6 @@ Default to this mode.</p></td>
<td><p> </p></td>
</tr>
- <tr>
- <td>database_name</td>
- <td><a href="#string">string</a></td>
- <td></td>
- <td><p> </p></td>
- </tr>
-
- <tr>
- <td>table_name</td>
- <td><a href="#string">string</a></td>
- <td></td>
- <td><p> </p></td>
- </tr>
-
<tr>
<td>sheet_id</td>
<td><a href="#int32">int32</a></td>
@@ -12235,147 +12213,78 @@ Default to this mode.</p></td>
</tr>
<tr>
- <td>character_set</td>
+ <td>environment_id</td>
<td><a href="#string">string</a></td>
<td></td>
- <td><p> </p></td>
+ <td><p>Create database fields. </p></td>
</tr>
<tr>
- <td>collation</td>
+ <td>database_name</td>
<td><a href="#string">string</a></td>
<td></td>
<td><p> </p></td>
</tr>
<tr>
- <td>environment_id</td>
+ <td>table_name</td>
<td><a href="#string">string</a></td>
<td></td>
<td><p> </p></td>
</tr>
<tr>
- <td>labels</td>
+ <td>character_set</td>
<td><a href="#string">string</a></td>
<td></td>
<td><p> </p></td>
</tr>
- </tbody>
- </table>
-
-
-
-
-
- <h3 id="bytebase.store.TaskDatabaseDataExportPayload">TaskDatabaseDataExportPayload</h3>
- <p>TaskDatabaseDataExportPayload is the task payload for database data export.</p>
-
-
- <table class="field-table">
- <thead>
- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
- </thead>
- <tbody>
-
<tr>
- <td>spec_id</td>
+ <td>collation</td>
<td><a href="#string">string</a></td>
<td></td>
- <td><p>common fields </p></td>
- </tr>
-
- <tr>
- <td>sheet_id</td>
- <td><a href="#int32">int32</a></td>
- <td></td>
<td><p> </p></td>
</tr>
<tr>
- <td>password</td>
+ <td>schema_version</td>
<td><a href="#string">string</a></td>
<td></td>
- <td><p> </p></td>
+ <td><p>Update database fields. </p></td>
</tr>
<tr>
- <td>format</td>
- <td><a href="#bytebase.store.ExportFormat">ExportFormat</a></td>
+ <td>pre_update_backup_detail</td>
+ <td><a href="#bytebase.store.PreUpdateBackupDetail">PreUpdateBackupDetail</a></td>
<td></td>
<td><p> </p></td>
</tr>
- </tbody>
- </table>
-
-
-
-
-
- <h3 id="bytebase.store.TaskDatabaseUpdatePayload">TaskDatabaseUpdatePayload</h3>
- <p>TaskDatabaseUpdatePayload is the task payload for updating database (DDL & DML).</p>
-
-
- <table class="field-table">
- <thead>
- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
- </thead>
- <tbody>
-
- <tr>
- <td>skipped</td>
- <td><a href="#bool">bool</a></td>
- <td></td>
- <td><p>common fields </p></td>
- </tr>
-
<tr>
- <td>skipped_reason</td>
- <td><a href="#string">string</a></td>
- <td></td>
- <td><p> </p></td>
+ <td>flags</td>
+ <td><a href="#bytebase.store.TaskPayload.FlagsEntry">TaskPayload.FlagsEntry</a></td>
+ <td>repeated</td>
+ <td><p>ghost flags. </p></td>
</tr>
<tr>
- <td>spec_id</td>
- <td><a href="#string">string</a></td>
+ <td>task_release_source</td>
+ <td><a href="#bytebase.store.TaskReleaseSource">TaskReleaseSource</a></td>
<td></td>
<td><p> </p></td>
</tr>
<tr>
- <td>schema_version</td>
+ <td>password</td>
<td><a href="#string">string</a></td>
<td></td>
- <td><p> </p></td>
+ <td><p>Export data fields. </p></td>
</tr>
<tr>
- <td>sheet_id</td>
- <td><a href="#int32">int32</a></td>
- <td></td>
- <td><p> </p></td>
- </tr>
-
- <tr>
- <td>pre_update_backup_detail</td>
- <td><a href="#bytebase.store.PreUpdateBackupDetail">PreUpdateBackupDetail</a></td>
- <td></td>
- <td><p> </p></td>
- </tr>
-
- <tr>
- <td>flags</td>
- <td><a href="#bytebase.store.TaskDatabaseUpdatePayload.FlagsEntry">TaskDatabaseUpdatePayload.FlagsEntry</a></td>
- <td>repeated</td>
- <td><p>flags is used for ghost sync </p></td>
- </tr>
-
- <tr>
- <td>task_release_source</td>
- <td><a href="#bytebase.store.TaskReleaseSource">TaskReleaseSource</a></td>
+ <td>format</td>
+ <td><a href="#bytebase.store.ExportFormat">ExportFormat</a></td>
<td></td>
<td><p> </p></td>
</tr>
@@ -12387,7 +12296,7 @@ Default to this mode.</p></td>
- <h3 id="bytebase.store.TaskDatabaseUpdatePayload.FlagsEntry">TaskDatabaseUpdatePayload.FlagsEntry</h3>
+ <h3 id="bytebase.store.TaskPayload.FlagsEntry">TaskPayload.FlagsEntry</h3>
<p></p>
diff --git a/proto/generated-go/store/task.pb.go b/proto/generated-go/store/task.pb.go
index ccefaa0b19..977fbc7e18 100644
--- a/proto/generated-go/store/task.pb.go
+++ b/proto/generated-go/store/task.pb.go
@@ -21,38 +21,46 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
-// TaskDatabaseCreatePayload is the task payload for creating databases.
-type TaskDatabaseCreatePayload struct {
+type TaskPayload struct {
state protoimpl.MessageState `protogen:"open.v1"`
// common fields
Skipped bool `protobuf:"varint,1,opt,name=skipped,proto3" json:"skipped,omitempty"`
SkippedReason string `protobuf:"bytes,2,opt,name=skipped_reason,json=skippedReason,proto3" json:"skipped_reason,omitempty"`
SpecId string `protobuf:"bytes,3,opt,name=spec_id,json=specId,proto3" json:"spec_id,omitempty"`
- DatabaseName string `protobuf:"bytes,5,opt,name=database_name,json=databaseName,proto3" json:"database_name,omitempty"`
- TableName string `protobuf:"bytes,6,opt,name=table_name,json=tableName,proto3" json:"table_name,omitempty"`
- SheetId int32 `protobuf:"varint,7,opt,name=sheet_id,json=sheetId,proto3" json:"sheet_id,omitempty"`
+ SheetId int32 `protobuf:"varint,4,opt,name=sheet_id,json=sheetId,proto3" json:"sheet_id,omitempty"`
+ // Create database fields.
+ EnvironmentId string `protobuf:"bytes,5,opt,name=environment_id,json=environmentId,proto3" json:"environment_id,omitempty"`
+ DatabaseName string `protobuf:"bytes,6,opt,name=database_name,json=databaseName,proto3" json:"database_name,omitempty"`
+ TableName string `protobuf:"bytes,7,opt,name=table_name,json=tableName,proto3" json:"table_name,omitempty"`
CharacterSet string `protobuf:"bytes,8,opt,name=character_set,json=characterSet,proto3" json:"character_set,omitempty"`
Collation string `protobuf:"bytes,9,opt,name=collation,proto3" json:"collation,omitempty"`
- EnvironmentId string `protobuf:"bytes,10,opt,name=environment_id,json=environmentId,proto3" json:"environment_id,omitempty"`
- Labels string `protobuf:"bytes,11,opt,name=labels,proto3" json:"labels,omitempty"`
+ // Update database fields.
+ SchemaVersion string `protobuf:"bytes,10,opt,name=schema_version,json=schemaVersion,proto3" json:"schema_version,omitempty"`
+ PreUpdateBackupDetail *PreUpdateBackupDetail `protobuf:"bytes,11,opt,name=pre_update_backup_detail,json=preUpdateBackupDetail,proto3" json:"pre_update_backup_detail,omitempty"`
+ // ghost flags.
+ Flags map[string]string `protobuf:"bytes,12,rep,name=flags,proto3" json:"flags,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
+ TaskReleaseSource *TaskReleaseSource `protobuf:"bytes,13,opt,name=task_release_source,json=taskReleaseSource,proto3" json:"task_release_source,omitempty"`
+ // Export data fields.
+ Password string `protobuf:"bytes,14,opt,name=password,proto3" json:"password,omitempty"`
+ Format ExportFormat `protobuf:"varint,15,opt,name=format,proto3,enum=bytebase.store.ExportFormat" json:"format,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
-func (x *TaskDatabaseCreatePayload) Reset() {
- *x = TaskDatabaseCreatePayload{}
+func (x *TaskPayload) Reset() {
+ *x = TaskPayload{}
mi := &file_store_task_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
-func (x *TaskDatabaseCreatePayload) String() string {
+func (x *TaskPayload) String() string {
return protoimpl.X.MessageStringOf(x)
}
-func (*TaskDatabaseCreatePayload) ProtoMessage() {}
+func (*TaskPayload) ProtoMessage() {}
-func (x *TaskDatabaseCreatePayload) ProtoReflect() protoreflect.Message {
+func (x *TaskPayload) ProtoReflect() protoreflect.Message {
mi := &file_store_task_proto_msgTypes[0]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@@ -64,248 +72,110 @@ func (x *TaskDatabaseCreatePayload) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x)
}
-// Deprecated: Use TaskDatabaseCreatePayload.ProtoReflect.Descriptor instead.
-func (*TaskDatabaseCreatePayload) Descriptor() ([]byte, []int) {
+// Deprecated: Use TaskPayload.ProtoReflect.Descriptor instead.
+func (*TaskPayload) Descriptor() ([]byte, []int) {
return file_store_task_proto_rawDescGZIP(), []int{0}
}
-func (x *TaskDatabaseCreatePayload) GetSkipped() bool {
+func (x *TaskPayload) GetSkipped() bool {
if x != nil {
return x.Skipped
}
return false
}
-func (x *TaskDatabaseCreatePayload) GetSkippedReason() string {
+func (x *TaskPayload) GetSkippedReason() string {
if x != nil {
return x.SkippedReason
}
return ""
}
-func (x *TaskDatabaseCreatePayload) GetSpecId() string {
+func (x *TaskPayload) GetSpecId() string {
if x != nil {
return x.SpecId
}
return ""
}
-func (x *TaskDatabaseCreatePayload) GetDatabaseName() string {
- if x != nil {
- return x.DatabaseName
- }
- return ""
-}
-
-func (x *TaskDatabaseCreatePayload) GetTableName() string {
- if x != nil {
- return x.TableName
- }
- return ""
-}
-
-func (x *TaskDatabaseCreatePayload) GetSheetId() int32 {
+func (x *TaskPayload) GetSheetId() int32 {
if x != nil {
return x.SheetId
}
return 0
}
-func (x *TaskDatabaseCreatePayload) GetCharacterSet() string {
- if x != nil {
- return x.CharacterSet
- }
- return ""
-}
-
-func (x *TaskDatabaseCreatePayload) GetCollation() string {
- if x != nil {
- return x.Collation
- }
- return ""
-}
-
-func (x *TaskDatabaseCreatePayload) GetEnvironmentId() string {
+func (x *TaskPayload) GetEnvironmentId() string {
if x != nil {
return x.EnvironmentId
}
return ""
}
-func (x *TaskDatabaseCreatePayload) GetLabels() string {
+func (x *TaskPayload) GetDatabaseName() string {
if x != nil {
- return x.Labels
+ return x.DatabaseName
}
return ""
}
-// TaskDatabaseUpdatePayload is the task payload for updating database (DDL & DML).
-type TaskDatabaseUpdatePayload struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- // common fields
- Skipped bool `protobuf:"varint,1,opt,name=skipped,proto3" json:"skipped,omitempty"`
- SkippedReason string `protobuf:"bytes,2,opt,name=skipped_reason,json=skippedReason,proto3" json:"skipped_reason,omitempty"`
- SpecId string `protobuf:"bytes,3,opt,name=spec_id,json=specId,proto3" json:"spec_id,omitempty"`
- SchemaVersion string `protobuf:"bytes,4,opt,name=schema_version,json=schemaVersion,proto3" json:"schema_version,omitempty"`
- SheetId int32 `protobuf:"varint,5,opt,name=sheet_id,json=sheetId,proto3" json:"sheet_id,omitempty"`
- PreUpdateBackupDetail *PreUpdateBackupDetail `protobuf:"bytes,6,opt,name=pre_update_backup_detail,json=preUpdateBackupDetail,proto3" json:"pre_update_backup_detail,omitempty"`
- // flags is used for ghost sync
- Flags map[string]string `protobuf:"bytes,7,rep,name=flags,proto3" json:"flags,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
- TaskReleaseSource *TaskReleaseSource `protobuf:"bytes,8,opt,name=task_release_source,json=taskReleaseSource,proto3" json:"task_release_source,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
-}
-
-func (x *TaskDatabaseUpdatePayload) Reset() {
- *x = TaskDatabaseUpdatePayload{}
- mi := &file_store_task_proto_msgTypes[1]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
-}
-
-func (x *TaskDatabaseUpdatePayload) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*TaskDatabaseUpdatePayload) ProtoMessage() {}
-
-func (x *TaskDatabaseUpdatePayload) ProtoReflect() protoreflect.Message {
- mi := &file_store_task_proto_msgTypes[1]
+func (x *TaskPayload) GetTableName() string {
if x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use TaskDatabaseUpdatePayload.ProtoReflect.Descriptor instead.
-func (*TaskDatabaseUpdatePayload) Descriptor() ([]byte, []int) {
- return file_store_task_proto_rawDescGZIP(), []int{1}
-}
-
-func (x *TaskDatabaseUpdatePayload) GetSkipped() bool {
- if x != nil {
- return x.Skipped
+ return x.TableName
}
- return false
+ return ""
}
-func (x *TaskDatabaseUpdatePayload) GetSkippedReason() string {
+func (x *TaskPayload) GetCharacterSet() string {
if x != nil {
- return x.SkippedReason
+ return x.CharacterSet
}
return ""
}
-func (x *TaskDatabaseUpdatePayload) GetSpecId() string {
+func (x *TaskPayload) GetCollation() string {
if x != nil {
- return x.SpecId
+ return x.Collation
}
return ""
}
-func (x *TaskDatabaseUpdatePayload) GetSchemaVersion() string {
+func (x *TaskPayload) GetSchemaVersion() string {
if x != nil {
return x.SchemaVersion
}
return ""
}
-func (x *TaskDatabaseUpdatePayload) GetSheetId() int32 {
- if x != nil {
- return x.SheetId
- }
- return 0
-}
-
-func (x *TaskDatabaseUpdatePayload) GetPreUpdateBackupDetail() *PreUpdateBackupDetail {
+func (x *TaskPayload) GetPreUpdateBackupDetail() *PreUpdateBackupDetail {
if x != nil {
return x.PreUpdateBackupDetail
}
return nil
}
-func (x *TaskDatabaseUpdatePayload) GetFlags() map[string]string {
+func (x *TaskPayload) GetFlags() map[string]string {
if x != nil {
return x.Flags
}
return nil
}
-func (x *TaskDatabaseUpdatePayload) GetTaskReleaseSource() *TaskReleaseSource {
+func (x *TaskPayload) GetTaskReleaseSource() *TaskReleaseSource {
if x != nil {
return x.TaskReleaseSource
}
return nil
}
-// TaskDatabaseDataExportPayload is the task payload for database data export.
-type TaskDatabaseDataExportPayload struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- // common fields
- SpecId string `protobuf:"bytes,1,opt,name=spec_id,json=specId,proto3" json:"spec_id,omitempty"`
- SheetId int32 `protobuf:"varint,2,opt,name=sheet_id,json=sheetId,proto3" json:"sheet_id,omitempty"`
- Password string `protobuf:"bytes,3,opt,name=password,proto3" json:"password,omitempty"`
- Format ExportFormat `protobuf:"varint,4,opt,name=format,proto3,enum=bytebase.store.ExportFormat" json:"format,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
-}
-
-func (x *TaskDatabaseDataExportPayload) Reset() {
- *x = TaskDatabaseDataExportPayload{}
- mi := &file_store_task_proto_msgTypes[2]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
-}
-
-func (x *TaskDatabaseDataExportPayload) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*TaskDatabaseDataExportPayload) ProtoMessage() {}
-
-func (x *TaskDatabaseDataExportPayload) ProtoReflect() protoreflect.Message {
- mi := &file_store_task_proto_msgTypes[2]
- if x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use TaskDatabaseDataExportPayload.ProtoReflect.Descriptor instead.
-func (*TaskDatabaseDataExportPayload) Descriptor() ([]byte, []int) {
- return file_store_task_proto_rawDescGZIP(), []int{2}
-}
-
-func (x *TaskDatabaseDataExportPayload) GetSpecId() string {
- if x != nil {
- return x.SpecId
- }
- return ""
-}
-
-func (x *TaskDatabaseDataExportPayload) GetSheetId() int32 {
- if x != nil {
- return x.SheetId
- }
- return 0
-}
-
-func (x *TaskDatabaseDataExportPayload) GetPassword() string {
+func (x *TaskPayload) GetPassword() string {
if x != nil {
return x.Password
}
return ""
}
-func (x *TaskDatabaseDataExportPayload) GetFormat() ExportFormat {
+func (x *TaskPayload) GetFormat() ExportFormat {
if x != nil {
return x.Format
}
@@ -322,7 +192,7 @@ type TaskReleaseSource struct {
func (x *TaskReleaseSource) Reset() {
*x = TaskReleaseSource{}
- mi := &file_store_task_proto_msgTypes[3]
+ mi := &file_store_task_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -334,7 +204,7 @@ func (x *TaskReleaseSource) String() string {
func (*TaskReleaseSource) ProtoMessage() {}
func (x *TaskReleaseSource) ProtoReflect() protoreflect.Message {
- mi := &file_store_task_proto_msgTypes[3]
+ mi := &file_store_task_proto_msgTypes[1]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -347,7 +217,7 @@ func (x *TaskReleaseSource) ProtoReflect() protoreflect.Message {
// Deprecated: Use TaskReleaseSource.ProtoReflect.Descriptor instead.
func (*TaskReleaseSource) Descriptor() ([]byte, []int) {
- return file_store_task_proto_rawDescGZIP(), []int{3}
+ return file_store_task_proto_rawDescGZIP(), []int{1}
}
func (x *TaskReleaseSource) GetFile() string {
@@ -365,74 +235,56 @@ var file_store_task_proto_rawDesc = string([]byte{
0x72, 0x65, 0x1a, 0x12, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1a, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x6c,
0x61, 0x6e, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x5f, 0x72, 0x75, 0x6e, 0x2e, 0x70, 0x72, 0x6f,
- 0x74, 0x6f, 0x22, 0xd6, 0x02, 0x0a, 0x19, 0x54, 0x61, 0x73, 0x6b, 0x44, 0x61, 0x74, 0x61, 0x62,
- 0x61, 0x73, 0x65, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64,
- 0x12, 0x18, 0x0a, 0x07, 0x73, 0x6b, 0x69, 0x70, 0x70, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
- 0x08, 0x52, 0x07, 0x73, 0x6b, 0x69, 0x70, 0x70, 0x65, 0x64, 0x12, 0x25, 0x0a, 0x0e, 0x73, 0x6b,
- 0x69, 0x70, 0x70, 0x65, 0x64, 0x5f, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01,
- 0x28, 0x09, 0x52, 0x0d, 0x73, 0x6b, 0x69, 0x70, 0x70, 0x65, 0x64, 0x52, 0x65, 0x61, 0x73, 0x6f,
- 0x6e, 0x12, 0x17, 0x0a, 0x07, 0x73, 0x70, 0x65, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01,
- 0x28, 0x09, 0x52, 0x06, 0x73, 0x70, 0x65, 0x63, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x64, 0x61,
- 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28,
- 0x09, 0x52, 0x0c, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12,
- 0x1d, 0x0a, 0x0a, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x06, 0x20,
- 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x19,
- 0x0a, 0x08, 0x73, 0x68, 0x65, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05,
- 0x52, 0x07, 0x73, 0x68, 0x65, 0x65, 0x74, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x68, 0x61,
- 0x72, 0x61, 0x63, 0x74, 0x65, 0x72, 0x5f, 0x73, 0x65, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09,
- 0x52, 0x0c, 0x63, 0x68, 0x61, 0x72, 0x61, 0x63, 0x74, 0x65, 0x72, 0x53, 0x65, 0x74, 0x12, 0x1c,
- 0x0a, 0x09, 0x63, 0x6f, 0x6c, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28,
- 0x09, 0x52, 0x09, 0x63, 0x6f, 0x6c, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x25, 0x0a, 0x0e,
- 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x0a,
- 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e,
- 0x74, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x18, 0x0b, 0x20,
- 0x01, 0x28, 0x09, 0x52, 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x22, 0xf0, 0x03, 0x0a, 0x19,
- 0x54, 0x61, 0x73, 0x6b, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x55, 0x70, 0x64, 0x61,
- 0x74, 0x65, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x6b, 0x69,
- 0x70, 0x70, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x6b, 0x69, 0x70,
- 0x70, 0x65, 0x64, 0x12, 0x25, 0x0a, 0x0e, 0x73, 0x6b, 0x69, 0x70, 0x70, 0x65, 0x64, 0x5f, 0x72,
- 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, 0x6b, 0x69,
- 0x70, 0x70, 0x65, 0x64, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x17, 0x0a, 0x07, 0x73, 0x70,
- 0x65, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x70, 0x65,
- 0x63, 0x49, 0x64, 0x12, 0x25, 0x0a, 0x0e, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x76, 0x65,
- 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, 0x63, 0x68,
- 0x65, 0x6d, 0x61, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x19, 0x0a, 0x08, 0x73, 0x68,
- 0x65, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x73, 0x68,
- 0x65, 0x65, 0x74, 0x49, 0x64, 0x12, 0x5e, 0x0a, 0x18, 0x70, 0x72, 0x65, 0x5f, 0x75, 0x70, 0x64,
- 0x61, 0x74, 0x65, 0x5f, 0x62, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x5f, 0x64, 0x65, 0x74, 0x61, 0x69,
- 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61,
- 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x50, 0x72, 0x65, 0x55, 0x70, 0x64, 0x61,
- 0x74, 0x65, 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x15,
- 0x70, 0x72, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x44,
- 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x4a, 0x0a, 0x05, 0x66, 0x6c, 0x61, 0x67, 0x73, 0x18, 0x07,
- 0x20, 0x03, 0x28, 0x0b, 0x32, 0x34, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e,
- 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61,
- 0x73, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e,
- 0x46, 0x6c, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x66, 0x6c, 0x61, 0x67,
- 0x73, 0x12, 0x51, 0x0a, 0x13, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73,
- 0x65, 0x5f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21,
+ 0x74, 0x6f, 0x22, 0xd4, 0x05, 0x0a, 0x0b, 0x54, 0x61, 0x73, 0x6b, 0x50, 0x61, 0x79, 0x6c, 0x6f,
+ 0x61, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x6b, 0x69, 0x70, 0x70, 0x65, 0x64, 0x18, 0x01, 0x20,
+ 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x6b, 0x69, 0x70, 0x70, 0x65, 0x64, 0x12, 0x25, 0x0a, 0x0e,
+ 0x73, 0x6b, 0x69, 0x70, 0x70, 0x65, 0x64, 0x5f, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x02,
+ 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, 0x6b, 0x69, 0x70, 0x70, 0x65, 0x64, 0x52, 0x65, 0x61,
+ 0x73, 0x6f, 0x6e, 0x12, 0x17, 0x0a, 0x07, 0x73, 0x70, 0x65, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x03,
+ 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x70, 0x65, 0x63, 0x49, 0x64, 0x12, 0x19, 0x0a, 0x08,
+ 0x73, 0x68, 0x65, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07,
+ 0x73, 0x68, 0x65, 0x65, 0x74, 0x49, 0x64, 0x12, 0x25, 0x0a, 0x0e, 0x65, 0x6e, 0x76, 0x69, 0x72,
+ 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52,
+ 0x0d, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x23,
+ 0x0a, 0x0d, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18,
+ 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x4e,
+ 0x61, 0x6d, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d,
+ 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x4e, 0x61,
+ 0x6d, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x68, 0x61, 0x72, 0x61, 0x63, 0x74, 0x65, 0x72, 0x5f,
+ 0x73, 0x65, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x68, 0x61, 0x72, 0x61,
+ 0x63, 0x74, 0x65, 0x72, 0x53, 0x65, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x6f, 0x6c, 0x6c, 0x61,
+ 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x6f, 0x6c, 0x6c,
+ 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x25, 0x0a, 0x0e, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f,
+ 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73,
+ 0x63, 0x68, 0x65, 0x6d, 0x61, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x5e, 0x0a, 0x18,
+ 0x70, 0x72, 0x65, 0x5f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x62, 0x61, 0x63, 0x6b, 0x75,
+ 0x70, 0x5f, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25,
0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e,
- 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x53, 0x6f, 0x75, 0x72, 0x63,
- 0x65, 0x52, 0x11, 0x74, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x53, 0x6f,
- 0x75, 0x72, 0x63, 0x65, 0x1a, 0x38, 0x0a, 0x0a, 0x46, 0x6c, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74,
- 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
- 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20,
- 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xa5,
- 0x01, 0x0a, 0x1d, 0x54, 0x61, 0x73, 0x6b, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x44,
- 0x61, 0x74, 0x61, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64,
- 0x12, 0x17, 0x0a, 0x07, 0x73, 0x70, 0x65, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
- 0x09, 0x52, 0x06, 0x73, 0x70, 0x65, 0x63, 0x49, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x73, 0x68, 0x65,
- 0x65, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x73, 0x68, 0x65,
- 0x65, 0x74, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64,
- 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64,
- 0x12, 0x34, 0x0a, 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e,
- 0x32, 0x1c, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72,
- 0x65, 0x2e, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x52, 0x06,
- 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x22, 0x27, 0x0a, 0x11, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65,
- 0x6c, 0x65, 0x61, 0x73, 0x65, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x66,
- 0x69, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x42,
- 0x14, 0x5a, 0x12, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x2d, 0x67, 0x6f, 0x2f,
- 0x73, 0x74, 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+ 0x50, 0x72, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x44,
+ 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x15, 0x70, 0x72, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65,
+ 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x3c, 0x0a, 0x05,
+ 0x66, 0x6c, 0x61, 0x67, 0x73, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x62, 0x79,
+ 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x54, 0x61, 0x73,
+ 0x6b, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x46, 0x6c, 0x61, 0x67, 0x73, 0x45, 0x6e,
+ 0x74, 0x72, 0x79, 0x52, 0x05, 0x66, 0x6c, 0x61, 0x67, 0x73, 0x12, 0x51, 0x0a, 0x13, 0x74, 0x61,
+ 0x73, 0x6b, 0x5f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x73, 0x6f, 0x75, 0x72, 0x63,
+ 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61,
+ 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x6c,
+ 0x65, 0x61, 0x73, 0x65, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x11, 0x74, 0x61, 0x73, 0x6b,
+ 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x1a, 0x0a,
+ 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52,
+ 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x34, 0x0a, 0x06, 0x66, 0x6f, 0x72,
+ 0x6d, 0x61, 0x74, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1c, 0x2e, 0x62, 0x79, 0x74, 0x65,
+ 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x78, 0x70, 0x6f, 0x72,
+ 0x74, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x52, 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x1a,
+ 0x38, 0x0a, 0x0a, 0x46, 0x6c, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a,
+ 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12,
+ 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05,
+ 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x27, 0x0a, 0x11, 0x54, 0x61, 0x73,
+ 0x6b, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x12,
+ 0x0a, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, 0x69,
+ 0x6c, 0x65, 0x42, 0x14, 0x5a, 0x12, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x2d,
+ 0x67, 0x6f, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
})
var (
@@ -447,21 +299,19 @@ func file_store_task_proto_rawDescGZIP() []byte {
return file_store_task_proto_rawDescData
}
-var file_store_task_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
+var file_store_task_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
var file_store_task_proto_goTypes = []any{
- (*TaskDatabaseCreatePayload)(nil), // 0: bytebase.store.TaskDatabaseCreatePayload
- (*TaskDatabaseUpdatePayload)(nil), // 1: bytebase.store.TaskDatabaseUpdatePayload
- (*TaskDatabaseDataExportPayload)(nil), // 2: bytebase.store.TaskDatabaseDataExportPayload
- (*TaskReleaseSource)(nil), // 3: bytebase.store.TaskReleaseSource
- nil, // 4: bytebase.store.TaskDatabaseUpdatePayload.FlagsEntry
- (*PreUpdateBackupDetail)(nil), // 5: bytebase.store.PreUpdateBackupDetail
- (ExportFormat)(0), // 6: bytebase.store.ExportFormat
+ (*TaskPayload)(nil), // 0: bytebase.store.TaskPayload
+ (*TaskReleaseSource)(nil), // 1: bytebase.store.TaskReleaseSource
+ nil, // 2: bytebase.store.TaskPayload.FlagsEntry
+ (*PreUpdateBackupDetail)(nil), // 3: bytebase.store.PreUpdateBackupDetail
+ (ExportFormat)(0), // 4: bytebase.store.ExportFormat
}
var file_store_task_proto_depIdxs = []int32{
- 5, // 0: bytebase.store.TaskDatabaseUpdatePayload.pre_update_backup_detail:type_name -> bytebase.store.PreUpdateBackupDetail
- 4, // 1: bytebase.store.TaskDatabaseUpdatePayload.flags:type_name -> bytebase.store.TaskDatabaseUpdatePayload.FlagsEntry
- 3, // 2: bytebase.store.TaskDatabaseUpdatePayload.task_release_source:type_name -> bytebase.store.TaskReleaseSource
- 6, // 3: bytebase.store.TaskDatabaseDataExportPayload.format:type_name -> bytebase.store.ExportFormat
+ 3, // 0: bytebase.store.TaskPayload.pre_update_backup_detail:type_name -> bytebase.store.PreUpdateBackupDetail
+ 2, // 1: bytebase.store.TaskPayload.flags:type_name -> bytebase.store.TaskPayload.FlagsEntry
+ 1, // 2: bytebase.store.TaskPayload.task_release_source:type_name -> bytebase.store.TaskReleaseSource
+ 4, // 3: bytebase.store.TaskPayload.format:type_name -> bytebase.store.ExportFormat
4, // [4:4] is the sub-list for method output_type
4, // [4:4] is the sub-list for method input_type
4, // [4:4] is the sub-list for extension type_name
@@ -482,7 +332,7 @@ func file_store_task_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_store_task_proto_rawDesc), len(file_store_task_proto_rawDesc)),
NumEnums: 0,
- NumMessages: 5,
+ NumMessages: 3,
NumExtensions: 0,
NumServices: 0,
},
diff --git a/proto/store/task.proto b/proto/store/task.proto
index cf8c4cf96a..1882771519 100644
--- a/proto/store/task.proto
+++ b/proto/store/task.proto
@@ -7,48 +7,30 @@ import "store/plan_check_run.proto";
option go_package = "generated-go/store";
-// TaskDatabaseCreatePayload is the task payload for creating databases.
-message TaskDatabaseCreatePayload {
+message TaskPayload {
// common fields
bool skipped = 1;
string skipped_reason = 2;
string spec_id = 3;
+ int32 sheet_id = 4;
- string database_name = 5;
- string table_name = 6;
- int32 sheet_id = 7;
+ // Create database fields.
+ string environment_id = 5;
+ string database_name = 6;
+ string table_name = 7;
string character_set = 8;
string collation = 9;
- string environment_id = 10;
- string labels = 11;
-}
-
-// TaskDatabaseUpdatePayload is the task payload for updating database (DDL & DML).
-message TaskDatabaseUpdatePayload {
- // common fields
- bool skipped = 1;
- string skipped_reason = 2;
- string spec_id = 3;
- string schema_version = 4;
- int32 sheet_id = 5;
-
- PreUpdateBackupDetail pre_update_backup_detail = 6;
-
- // flags is used for ghost sync
- map<string, string> flags = 7;
-
- TaskReleaseSource task_release_source = 8;
-}
-
-// TaskDatabaseDataExportPayload is the task payload for database data export.
-message TaskDatabaseDataExportPayload {
- // common fields
- string spec_id = 1;
+ // Update database fields.
+ string schema_version = 10;
+ PreUpdateBackupDetail pre_update_backup_detail = 11;
+ // ghost flags.
+ map<string, string> flags = 12;
+ TaskReleaseSource task_release_source = 13;
- int32 sheet_id = 2;
- string password = 3;
- ExportFormat format = 4;
+ // Export data fields.
+ string password = 14;
+ ExportFormat format = 15;
}
message TaskReleaseSource {