Skip to content

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

chore: plan check run instance id (#15227)

Danny Xu589881c0dad4
diff --git a/backend/api/v1/instance_service.go b/backend/api/v1/instance_service.go
index 2db8195094..1de2c671e2 100644
--- a/backend/api/v1/instance_service.go
+++ b/backend/api/v1/instance_service.go
@@ -685,7 +685,7 @@ func (s *InstanceService) AddDataSource(ctx context.Context, request *v1pb.AddDa
return nil, status.Error(codes.PermissionDenied, err.Error())
}
- if err := s.store.AddDataSourceToInstanceV2(ctx, instance.UID, instance.ResourceID, dataSource); err != nil {
+ if err := s.store.AddDataSourceToInstanceV2(ctx, instance.ResourceID, dataSource); err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
@@ -736,7 +736,6 @@ func (s *InstanceService) UpdateDataSource(ctx context.Context, request *v1pb.Up
}
patch := &store.UpdateDataSourceMessage{
- InstanceUID: instance.UID,
InstanceID: instance.ResourceID,
DataSourceID: request.DataSource.Id,
}
@@ -931,7 +930,7 @@ func (s *InstanceService) RemoveDataSource(ctx context.Context, request *v1pb.Re
return nil, status.Errorf(codes.InvalidArgument, "only support remove read-only data source")
}
- if err := s.store.RemoveDataSourceV2(ctx, instance.UID, instance.ResourceID, dataSource.ID); err != nil {
+ if err := s.store.RemoveDataSourceV2(ctx, instance.ResourceID, dataSource.ID); err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
diff --git a/backend/api/v1/plan_service_plan_check.go b/backend/api/v1/plan_service_plan_check.go
index 4d8ba62673..a8aa90aa7c 100644
--- a/backend/api/v1/plan_service_plan_check.go
+++ b/backend/api/v1/plan_service_plan_check.go
@@ -62,10 +62,10 @@ func getPlanCheckRunsFromPlanSpecs(ctx context.Context, s *store.Store, plan *st
return nil, errors.Wrapf(err, "failed to get database matrix from deployment schedule")
}
- scheduledDatabase := map[int]bool{}
+ scheduledDatabase := map[string]bool{}
for _, dbs := range matrix {
for _, db := range dbs {
- scheduledDatabase[db.UID] = true
+ scheduledDatabase[db.String()] = true
}
}
@@ -85,7 +85,7 @@ func getPlanCheckRunsFromPlanSpecs(ctx context.Context, s *store.Store, plan *st
return planCheckRuns, nil
}
-func getPlanCheckRunsFromSpec(ctx context.Context, s *store.Store, plan *store.PlanMessage, spec *storepb.PlanConfig_Spec, scheduledDatabase map[int]bool) ([]*store.PlanCheckRunMessage, error) {
+func getPlanCheckRunsFromSpec(ctx context.Context, s *store.Store, plan *store.PlanMessage, spec *storepb.PlanConfig_Spec, scheduledDatabase map[string]bool) ([]*store.PlanCheckRunMessage, error) {
switch config := spec.Config.(type) {
case *storepb.PlanConfig_Spec_CreateDatabaseConfig:
// TODO(p0ny): implement
@@ -107,7 +107,7 @@ func getPlanCheckRunsFromSpec(ctx context.Context, s *store.Store, plan *store.P
return nil, nil
}
-func getPlanCheckRunsFromChangeDatabaseConfigDatabaseGroupTarget(ctx context.Context, s *store.Store, plan *store.PlanMessage, config *storepb.PlanConfig_ChangeDatabaseConfig, scheduledDatabase map[int]bool) ([]*store.PlanCheckRunMessage, error) {
+func getPlanCheckRunsFromChangeDatabaseConfigDatabaseGroupTarget(ctx context.Context, s *store.Store, plan *store.PlanMessage, config *storepb.PlanConfig_ChangeDatabaseConfig, scheduledDatabase map[string]bool) ([]*store.PlanCheckRunMessage, error) {
switch config.Type {
case storepb.PlanConfig_ChangeDatabaseConfig_MIGRATE:
case storepb.PlanConfig_ChangeDatabaseConfig_DATA:
@@ -166,7 +166,7 @@ func getPlanCheckRunsFromChangeDatabaseConfigDatabaseGroupTarget(ctx context.Con
return planCheckRuns, nil
}
-func getPlanCheckRunsFromChangeDatabaseConfigDatabaseTarget(ctx context.Context, s *store.Store, plan *store.PlanMessage, config *storepb.PlanConfig_ChangeDatabaseConfig, scheduledDatabase map[int]bool) ([]*store.PlanCheckRunMessage, error) {
+func getPlanCheckRunsFromChangeDatabaseConfigDatabaseTarget(ctx context.Context, s *store.Store, plan *store.PlanMessage, config *storepb.PlanConfig_ChangeDatabaseConfig, scheduledDatabase map[string]bool) ([]*store.PlanCheckRunMessage, error) {
instanceID, databaseName, err := common.GetInstanceDatabaseID(config.Target)
if err != nil {
return nil, errors.Wrapf(err, "failed to get instance and database from target %q", config.Target)
@@ -200,8 +200,8 @@ func getPlanCheckRunsFromChangeDatabaseConfigDatabaseTarget(ctx context.Context,
return getPlanCheckRunsFromChangeDatabaseConfigForDatabase(ctx, s, plan, config, sheetUID, database, scheduledDatabase)
}
-func getPlanCheckRunsFromChangeDatabaseConfigForDatabase(ctx context.Context, s *store.Store, plan *store.PlanMessage, config *storepb.PlanConfig_ChangeDatabaseConfig, sheetUID int, database *store.DatabaseMessage, scheduledDatabase map[int]bool) ([]*store.PlanCheckRunMessage, error) {
- if !scheduledDatabase[database.UID] {
+func getPlanCheckRunsFromChangeDatabaseConfigForDatabase(ctx context.Context, s *store.Store, plan *store.PlanMessage, config *storepb.PlanConfig_ChangeDatabaseConfig, sheetUID int, database *store.DatabaseMessage, scheduledDatabase map[string]bool) ([]*store.PlanCheckRunMessage, error) {
+ if !scheduledDatabase[database.String()] {
return nil, nil
}
@@ -223,7 +223,7 @@ func getPlanCheckRunsFromChangeDatabaseConfigForDatabase(ctx context.Context, s
Config: &storepb.PlanCheckRunConfig{
SheetUid: int32(sheetUID),
ChangeDatabaseType: convertToChangeDatabaseType(config.Type),
- InstanceUid: int32(instance.UID),
+ InstanceId: instance.ResourceID,
DatabaseName: database.DatabaseName,
},
})
@@ -245,7 +245,7 @@ func getPlanCheckRunsFromChangeDatabaseConfigForDatabase(ctx context.Context, s
Config: &storepb.PlanCheckRunConfig{
SheetUid: int32(sheetUID),
ChangeDatabaseType: convertToChangeDatabaseType(config.Type),
- InstanceUid: int32(instance.UID),
+ InstanceId: instance.ResourceID,
DatabaseName: database.DatabaseName,
PreUpdateBackupDetail: preUpdateBackupDetail,
},
@@ -257,7 +257,7 @@ func getPlanCheckRunsFromChangeDatabaseConfigForDatabase(ctx context.Context, s
Config: &storepb.PlanCheckRunConfig{
SheetUid: int32(sheetUID),
ChangeDatabaseType: convertToChangeDatabaseType(config.Type),
- InstanceUid: int32(instance.UID),
+ InstanceId: instance.ResourceID,
DatabaseName: database.DatabaseName,
},
})
@@ -269,7 +269,7 @@ func getPlanCheckRunsFromChangeDatabaseConfigForDatabase(ctx context.Context, s
Config: &storepb.PlanCheckRunConfig{
SheetUid: int32(sheetUID),
ChangeDatabaseType: convertToChangeDatabaseType(config.Type),
- InstanceUid: int32(instance.UID),
+ InstanceId: instance.ResourceID,
DatabaseName: database.DatabaseName,
GhostFlags: config.GhostFlags,
},
@@ -337,7 +337,7 @@ func getPlanCheckRunsFromExportDataConfigForDatabase(ctx context.Context, s *sto
Config: &storepb.PlanCheckRunConfig{
SheetUid: int32(sheetUID),
ChangeDatabaseType: storepb.PlanCheckRunConfig_DML,
- InstanceUid: int32(instance.UID),
+ InstanceId: instance.ResourceID,
DatabaseName: database.DatabaseName,
},
})
diff --git a/backend/api/v1/release_service_check.go b/backend/api/v1/release_service_check.go
index 52eefbbd00..825e9c3471 100644
--- a/backend/api/v1/release_service_check.go
+++ b/backend/api/v1/release_service_check.go
@@ -230,18 +230,18 @@ func (s *ReleaseService) runSQLReviewCheckForFile(
dbSchema, err := s.store.GetDBSchema(ctx, database.InstanceID, database.DatabaseName)
if err != nil {
- return storepb.Advice_ERROR, nil, errors.Wrapf(err, "failed to fetch database schema for database %v", database.UID)
+ return storepb.Advice_ERROR, nil, errors.Wrapf(err, "failed to fetch database schema for database %s", database.String())
}
if dbSchema == nil {
if err := s.schemaSyncer.SyncDatabaseSchema(ctx, database, true /* force */); err != nil {
- return storepb.Advice_ERROR, nil, errors.Wrapf(err, "failed to sync database schema for database %v", database.UID)
+ return storepb.Advice_ERROR, nil, errors.Wrapf(err, "failed to sync database schema for database %s", database.String())
}
dbSchema, err = s.store.GetDBSchema(ctx, database.InstanceID, database.DatabaseName)
if err != nil {
- return storepb.Advice_ERROR, nil, errors.Wrapf(err, "failed to fetch database schema for database %v", database.UID)
+ return storepb.Advice_ERROR, nil, errors.Wrapf(err, "failed to fetch database schema for database %s", database.String())
}
if dbSchema == nil {
- return storepb.Advice_ERROR, nil, errors.Wrapf(err, "cannot found schema for database %v", database.UID)
+ return storepb.Advice_ERROR, nil, errors.Wrapf(err, "cannot found schema for database %s", database.String())
}
}
diff --git a/backend/api/v1/rollout_service_converter.go b/backend/api/v1/rollout_service_converter.go
index 5ef10fc7fd..8fa7dfe224 100644
--- a/backend/api/v1/rollout_service_converter.go
+++ b/backend/api/v1/rollout_service_converter.go
@@ -357,7 +357,7 @@ func convertToPlanCheckRun(ctx context.Context, s *store.Store, projectID string
CreateTime: timestamppb.New(run.CreatedAt),
Type: convertToPlanCheckRunType(run.Type),
Status: convertToPlanCheckRunStatus(run.Status),
- Target: "",
+ Target: common.FormatDatabase(run.Config.InstanceId, run.Config.DatabaseName),
Sheet: "",
Results: convertToPlanCheckRunResults(run.Result.Results),
Error: run.Result.Error,
@@ -374,14 +374,6 @@ func convertToPlanCheckRun(ctx context.Context, s *store.Store, projectID string
converted.Sheet = common.FormatSheet(projectID, sheet.UID)
}
- instanceUID := int(run.Config.InstanceUid)
- databaseName := run.Config.DatabaseName
- instance, err := s.GetInstanceV2(ctx, &store.FindInstanceMessage{UID: &instanceUID})
- if err != nil {
- return nil, errors.Wrapf(err, "failed to get instance")
- }
- converted.Target = common.FormatDatabase(instance.ResourceID, databaseName)
-
return converted, nil
}
diff --git a/backend/api/v1/sql_service.go b/backend/api/v1/sql_service.go
index bfbdfbd50f..1679d9e70f 100644
--- a/backend/api/v1/sql_service.go
+++ b/backend/api/v1/sql_service.go
@@ -1380,18 +1380,18 @@ func (s *SQLService) SQLReviewCheck(
if dbMetadata == nil {
dbSchema, err := s.store.GetDBSchema(ctx, database.InstanceID, database.DatabaseName)
if err != nil {
- return storepb.Advice_ERROR, nil, errors.Wrapf(err, "failed to fetch database schema for database %v", database.UID)
+ return storepb.Advice_ERROR, nil, errors.Wrapf(err, "failed to fetch database schema for database %s", database.String())
}
if dbSchema == nil {
if err := s.schemaSyncer.SyncDatabaseSchema(ctx, database, true /* force */); err != nil {
- return storepb.Advice_ERROR, nil, errors.Wrapf(err, "failed to sync database schema for database %v", database.UID)
+ return storepb.Advice_ERROR, nil, errors.Wrapf(err, "failed to sync database schema for database %s", database.String())
}
dbSchema, err = s.store.GetDBSchema(ctx, database.InstanceID, database.DatabaseName)
if err != nil {
- return storepb.Advice_ERROR, nil, errors.Wrapf(err, "failed to fetch database schema for database %v", database.UID)
+ return storepb.Advice_ERROR, nil, errors.Wrapf(err, "failed to fetch database schema for database %s", database.String())
}
if dbSchema == nil {
- return storepb.Advice_ERROR, nil, errors.Wrapf(err, "cannot found schema for database %v", database.UID)
+ return storepb.Advice_ERROR, nil, errors.Wrapf(err, "cannot found schema for database %s", database.String())
}
}
dbMetadata = dbSchema.GetMetadata()
diff --git a/backend/component/ghost/config.go b/backend/component/ghost/config.go
index 292f74755b..f99aa40f49 100644
--- a/backend/component/ghost/config.go
+++ b/backend/component/ghost/config.go
@@ -176,13 +176,13 @@ func GetUserFlags(flags map[string]string) (*UserFlags, error) {
return f, nil
}
-func getSocketFilename(taskID int, databaseID int, databaseName, tableName string) string {
- return fmt.Sprintf("/tmp/gh-ost.%v.%v.%v.%v.sock", taskID, databaseID, databaseName, tableName)
+func getSocketFilename(taskID int) string {
+ return fmt.Sprintf("/tmp/gh-ost.%d.sock", taskID)
}
// GetPostponeFlagFilename gets the postpone flag filename for gh-ost.
-func GetPostponeFlagFilename(taskID int, databaseID int, databaseName, tableName string) string {
- return fmt.Sprintf("/tmp/gh-ost.%v.%v.%v.%v.postponeFlag", taskID, databaseID, databaseName, tableName)
+func GetPostponeFlagFilename(taskID int) string {
+ return fmt.Sprintf("/tmp/gh-ost.%d.postponeFlag", taskID)
}
// NewMigrationContext is the context for gh-ost migration.
@@ -273,8 +273,8 @@ func NewMigrationContext(ctx context.Context, taskID int, database *store.Databa
}
migrationContext.OriginalTableName = parser.GetExplicitTable()
}
- migrationContext.ServeSocketFile = getSocketFilename(taskID, database.UID, database.DatabaseName, tableName)
- migrationContext.PostponeCutOverFlagFile = GetPostponeFlagFilename(taskID, database.UID, database.DatabaseName, tableName)
+ migrationContext.ServeSocketFile = getSocketFilename(taskID)
+ migrationContext.PostponeCutOverFlagFile = GetPostponeFlagFilename(taskID)
migrationContext.TimestampOldTable = defaultConfig.timestampOldTable
migrationContext.SetHeartbeatIntervalMilliseconds(defaultConfig.heartbeatIntervalMilliseconds)
migrationContext.SetNiceRatio(defaultConfig.niceRatio)
diff --git a/backend/migrator/migration/3.4/0015##plan_check_run_uid.sql b/backend/migrator/migration/3.4/0015##plan_check_run_uid.sql
new file mode 100644
index 0000000000..334778a639
--- /dev/null
+++ b/backend/migrator/migration/3.4/0015##plan_check_run_uid.sql
@@ -0,0 +1,6 @@
+UPDATE plan_check_run
+SET config = (config || jsonb_build_object(
+ 'instanceId',
+ (select resource_id from instance where instance.id = (config->'instanceUid')::integer)
+ )) - 'instanceUid'
+WHERE config ? 'instanceUid';
\ No newline at end of file
diff --git a/backend/migrator/migrator_test.go b/backend/migrator/migrator_test.go
index 7d81fb2c01..1c3717020b 100644
--- a/backend/migrator/migrator_test.go
+++ b/backend/migrator/migrator_test.go
@@ -212,5 +212,5 @@ func TestMigrationCompatibility(t *testing.T) {
func TestGetCutoffVersion(t *testing.T) {
releaseVersion, err := getProdCutoffVersion()
require.NoError(t, err)
- require.Equal(t, semver.MustParse("3.4.14"), releaseVersion)
+ require.Equal(t, semver.MustParse("3.4.15"), releaseVersion)
}
diff --git a/backend/plugin/db/driver.go b/backend/plugin/db/driver.go
index 5ac6479bec..89e3b42443 100644
--- a/backend/plugin/db/driver.go
+++ b/backend/plugin/db/driver.go
@@ -146,25 +146,6 @@ const (
Failed MigrationStatus = "FAILED"
)
-// MigrationInfo is the API message for migration info.
-type MigrationInfo struct {
- DatabaseID *int
-
- ReleaseVersion string
- Namespace string
- Database string
- Environment string
- Source MigrationSource
- Type MigrationType
- Status MigrationStatus
- Description string
- // Payload contains JSON-encoded string of VCS push event if the migration is triggered by a VCS push event.
- Payload *storepb.InstanceChangeHistoryPayload
-
- SheetUID *int
- Sheet *string
-}
-
// ConnectionConfig is the configuration for connections.
type ConnectionConfig struct {
Host string
diff --git a/backend/runner/approval/runner.go b/backend/runner/approval/runner.go
index eed6bb4f99..d6b36e1b1f 100644
--- a/backend/runner/approval/runner.go
+++ b/backend/runner/approval/runner.go
@@ -365,13 +365,13 @@ func (r *Runner) getDatabaseGeneralIssueRisk(ctx context.Context, issue *store.I
return 0, store.RiskSourceUnknown, false, errors.Wrapf(err, "failed to list plan check runs for plan %v", plan.UID)
}
type Key struct {
- InstanceUID int
+ InstanceID string
DatabaseName string
}
latestPlanCheckRun := map[Key]*store.PlanCheckRunMessage{}
for _, run := range planCheckRuns {
key := Key{
- InstanceUID: int(run.Config.InstanceUid),
+ InstanceID: run.Config.InstanceId,
DatabaseName: run.Config.DatabaseName,
}
latestPlanCheckRun[key] = run
@@ -510,7 +510,7 @@ func (r *Runner) getDatabaseGeneralIssueRisk(ctx context.Context, issue *store.I
}
if run, ok := latestPlanCheckRun[Key{
- InstanceUID: instance.UID,
+ InstanceID: instance.ResourceID,
DatabaseName: databaseName,
}]; ok {
for _, result := range run.Result.Results {
diff --git a/backend/runner/mail/slow_query_weekly_mail.go b/backend/runner/mail/slow_query_weekly_mail.go
index d5eb9e3760..68147fd5fe 100644
--- a/backend/runner/mail/slow_query_weekly_mail.go
+++ b/backend/runner/mail/slow_query_weekly_mail.go
@@ -644,7 +644,7 @@ func (s *SlowQueryWeeklyMailSender) generateEnvironmentContent(
hasSlowQueryInInstance = true
beginUnix := beginDate.Truncate(24 * time.Hour).UTC().Unix()
endUnix := endDate.Truncate(24 * time.Hour).Add(-1 * time.Second).UTC().Unix()
- instanceURL := fmt.Sprintf("%s/slow-query?instance=%d&fromTime=%d&toTime=%d", strings.TrimSuffix(visitURL, "/"), instance.UID, beginUnix, endUnix)
+ instanceURL := fmt.Sprintf("%s/slow-query?instance=%s&fromTime=%d&toTime=%d", strings.TrimSuffix(visitURL, "/"), instance.ResourceID, beginUnix, endUnix)
instanceHeaderString := strings.ReplaceAll(string(instanceHeader), "{{INSTANCE_LINK}}", instanceURL)
instanceHeaderString = strings.ReplaceAll(instanceHeaderString, "{{INSTANCE_NAME}}", instance.Title)
if _, err := buf.WriteString(instanceHeaderString); err != nil {
diff --git a/backend/runner/plancheck/database_connect_executor.go b/backend/runner/plancheck/database_connect_executor.go
index 8b57d15f35..e4493becfa 100644
--- a/backend/runner/plancheck/database_connect_executor.go
+++ b/backend/runner/plancheck/database_connect_executor.go
@@ -31,13 +31,12 @@ type DatabaseConnectExecutor struct {
// Run runs the executor.
func (e *DatabaseConnectExecutor) Run(ctx context.Context, config *storepb.PlanCheckRunConfig) ([]*storepb.PlanCheckRunResult_Result, error) {
- instanceUID := int(config.InstanceUid)
- instance, err := e.store.GetInstanceV2(ctx, &store.FindInstanceMessage{UID: &instanceUID})
+ instance, err := e.store.GetInstanceV2(ctx, &store.FindInstanceMessage{ResourceID: &config.InstanceId})
if err != nil {
- return nil, errors.Wrapf(err, "failed to get instance UID %v", instanceUID)
+ return nil, errors.Wrapf(err, "failed to get instance %s", config.InstanceId)
}
if instance == nil {
- return nil, errors.Errorf("instance not found UID %v", instanceUID)
+ return nil, errors.Errorf("instance %s not found ", config.InstanceId)
}
database, err := e.store.GetDatabaseV2(ctx, &store.FindDatabaseMessage{InstanceID: &instance.ResourceID, DatabaseName: &config.DatabaseName})
diff --git a/backend/runner/plancheck/ghost_sync_executor.go b/backend/runner/plancheck/ghost_sync_executor.go
index 5647ceaab9..969901fa22 100644
--- a/backend/runner/plancheck/ghost_sync_executor.go
+++ b/backend/runner/plancheck/ghost_sync_executor.go
@@ -57,13 +57,12 @@ func (e *GhostSyncExecutor) Run(ctx context.Context, config *storepb.PlanCheckRu
}
}()
- instanceUID := int(config.InstanceUid)
- instance, err := e.store.GetInstanceV2(ctx, &store.FindInstanceMessage{UID: &instanceUID})
+ instance, err := e.store.GetInstanceV2(ctx, &store.FindInstanceMessage{ResourceID: &config.InstanceId})
if err != nil {
- return nil, errors.Wrapf(err, "failed to get instance UID %v", instanceUID)
+ return nil, errors.Wrapf(err, "failed to get instance %s", config.InstanceId)
}
if instance == nil {
- return nil, errors.Errorf("instance not found UID %v", instanceUID)
+ return nil, errors.Errorf("instance %s not found", config.InstanceId)
}
database, err := e.store.GetDatabaseV2(ctx, &store.FindDatabaseMessage{InstanceID: &instance.ResourceID, DatabaseName: &config.DatabaseName})
diff --git a/backend/runner/plancheck/scheduler.go b/backend/runner/plancheck/scheduler.go
index 68cd7474c1..4c7e367911 100644
--- a/backend/runner/plancheck/scheduler.go
+++ b/backend/runner/plancheck/scheduler.go
@@ -105,10 +105,9 @@ func (s *Scheduler) runPlanCheckRun(ctx context.Context, planCheckRun *store.Pla
return
}
- instanceUID := int(planCheckRun.Config.InstanceUid)
- instance, err := s.store.GetInstanceV2(ctx, &store.FindInstanceMessage{UID: &instanceUID})
+ instance, err := s.store.GetInstanceV2(ctx, &store.FindInstanceMessage{ResourceID: &planCheckRun.Config.InstanceId})
if err != nil {
- slog.Error("failed to find instance", slog.Int("uid", planCheckRun.UID), slog.Int64("plan_uid", planCheckRun.PlanUID), slog.Int("instance", instanceUID))
+ slog.Error("failed to find instance", slog.Int("uid", planCheckRun.UID), slog.Int64("plan_uid", planCheckRun.PlanUID), slog.String("instance", planCheckRun.Config.InstanceId))
return
}
diff --git a/backend/runner/plancheck/statement_advise_executor.go b/backend/runner/plancheck/statement_advise_executor.go
index 8fd61c13f4..7c7f7828e9 100644
--- a/backend/runner/plancheck/statement_advise_executor.go
+++ b/backend/runner/plancheck/statement_advise_executor.go
@@ -93,13 +93,12 @@ func (e *StatementAdviseExecutor) Run(ctx context.Context, config *storepb.PlanC
changeType := config.ChangeDatabaseType
preUpdateBackupDetail := config.PreUpdateBackupDetail
- instanceUID := int(config.InstanceUid)
- instance, err := e.store.GetInstanceV2(ctx, &store.FindInstanceMessage{UID: &instanceUID})
+ instance, err := e.store.GetInstanceV2(ctx, &store.FindInstanceMessage{ResourceID: &config.InstanceId})
if err != nil {
- return nil, errors.Wrapf(err, "failed to get instance UID %v", instanceUID)
+ return nil, errors.Wrapf(err, "failed to get instance %s", config.InstanceId)
}
if instance == nil {
- return nil, errors.Errorf("instance not found UID %v", instanceUID)
+ return nil, errors.Errorf("instance %s not found", config.InstanceId)
}
if !common.StatementAdviseEngines[instance.Engine] {
return []*storepb.PlanCheckRunResult_Result{
@@ -152,10 +151,10 @@ func (e *StatementAdviseExecutor) runReview(
return nil, err
}
if dbSchema == nil {
- return nil, errors.Errorf("database schema not found: %d", database.UID)
+ return nil, errors.Errorf("database schema %s not found", database.String())
}
if dbSchema.GetMetadata() == nil {
- return nil, errors.Errorf("database schema metadata not found: %d", database.UID)
+ return nil, errors.Errorf("database schema metadata %s not found", database.String())
}
reviewConfig, err := e.store.GetReviewConfigForDatabase(ctx, database)
diff --git a/backend/runner/plancheck/statement_report_executor.go b/backend/runner/plancheck/statement_report_executor.go
index c4f0c6df42..90613aff12 100644
--- a/backend/runner/plancheck/statement_report_executor.go
+++ b/backend/runner/plancheck/statement_report_executor.go
@@ -69,13 +69,12 @@ func (e *StatementReportExecutor) Run(ctx context.Context, config *storepb.PlanC
return nil, err
}
- instanceUID := int(config.InstanceUid)
- instance, err := e.store.GetInstanceV2(ctx, &store.FindInstanceMessage{UID: &instanceUID})
+ instance, err := e.store.GetInstanceV2(ctx, &store.FindInstanceMessage{ResourceID: &config.InstanceId})
if err != nil {
- return nil, errors.Wrapf(err, "failed to get instance UID %v", instanceUID)
+ return nil, errors.Wrapf(err, "failed to get instance %v", config.InstanceId)
}
if instance == nil {
- return nil, errors.Errorf("instance not found UID %v", instanceUID)
+ return nil, errors.Errorf("instance %s not found", config.InstanceId)
}
if !common.StatementReportEngines[instance.Engine] {
return []*storepb.PlanCheckRunResult_Result{
@@ -142,10 +141,10 @@ func GetSQLSummaryReport(ctx context.Context, stores *store.Store, sheetManager
return nil, err
}
if databaseSchema == nil {
- return nil, errors.Errorf("database schema not found: %d", database.UID)
+ return nil, errors.Errorf("database schema %s not found", database.String())
}
if databaseSchema.GetMetadata() == nil {
- return nil, errors.Errorf("database schema metadata not found: %d", database.UID)
+ return nil, errors.Errorf("database schema metadata %s not found", database.String())
}
instance, err := stores.GetInstanceV2(ctx, &store.FindInstanceMessage{ResourceID: &database.InstanceID})
if err != nil {
diff --git a/backend/runner/schemasync/syncer.go b/backend/runner/schemasync/syncer.go
index 80fd140c45..0bbd6922c7 100644
--- a/backend/runner/schemasync/syncer.go
+++ b/backend/runner/schemasync/syncer.go
@@ -61,7 +61,7 @@ type Syncer struct {
stateCfg *state.State
profile *config.Profile
licenseService enterprise.LicenseService
- databaseSyncMap sync.Map // map[int]*store.DatabaseMessage
+ databaseSyncMap sync.Map // map[string]*store.DatabaseMessage
}
// Run will run the schema syncer once.
@@ -218,7 +218,7 @@ func (s *Syncer) trySyncAll(ctx context.Context) {
continue
}
- s.databaseSyncMap.Store(database.UID, database)
+ s.databaseSyncMap.Store(database.String(), database)
}
}
@@ -239,7 +239,7 @@ func (s *Syncer) SyncAllDatabases(ctx context.Context, instance *store.InstanceM
if database.SyncState != api.OK {
continue
}
- s.databaseSyncMap.Store(database.UID, database)
+ s.databaseSyncMap.Store(database.String(), database)
}
}
@@ -249,7 +249,7 @@ func (s *Syncer) SyncDatabasesAsync(databases []*store.DatabaseMessage) {
if database.SyncState != api.OK {
continue
}
- s.databaseSyncMap.Store(database.UID, database)
+ s.databaseSyncMap.Store(database.String(), database)
}
}
diff --git a/backend/runner/slowquerysync/syncer.go b/backend/runner/slowquerysync/syncer.go
index b4dc8f7cae..f41e2a9697 100644
--- a/backend/runner/slowquerysync/syncer.go
+++ b/backend/runner/slowquerysync/syncer.go
@@ -160,9 +160,7 @@ func (s *Syncer) syncPostgreSQLSlowQuery(ctx context.Context, instance *store.In
return driver.CheckSlowQueryLogEnabled(ctx)
}(); err != nil {
slog.Warn("pg_stat_statements is not enabled",
- slog.String("instance", instance.ResourceID),
- slog.String("database", database.DatabaseName),
- slog.Int("databaseID", database.UID),
+ slog.String("database", database.String()),
log.BBError(err))
continue
}
@@ -208,9 +206,7 @@ func (s *Syncer) syncPostgreSQLSlowQuery(ctx context.Context, instance *store.In
})
if err != nil {
slog.Warn("Failed to list slow query logs",
- slog.String("instance", instance.ResourceID),
- slog.String("database", database.DatabaseName),
- slog.Int("databaseID", database.UID),
+ slog.String("database", database.String()),
log.BBError(err))
logs = nil
}
@@ -225,9 +221,7 @@ func (s *Syncer) syncPostgreSQLSlowQuery(ctx context.Context, instance *store.In
SlowLog: statistics,
}); err != nil {
slog.Warn("Failed to upsert slow query log",
- slog.String("instance", instance.ResourceID),
- slog.String("database", database.DatabaseName),
- slog.Int("databaseID", database.UID),
+ slog.String("database", database.String()),
log.BBError(err))
}
}
diff --git a/backend/runner/taskrun/database_create_executor.go b/backend/runner/taskrun/database_create_executor.go
index d688671c89..c32133d23b 100644
--- a/backend/runner/taskrun/database_create_executor.go
+++ b/backend/runner/taskrun/database_create_executor.go
@@ -155,16 +155,8 @@ func (exec *DatabaseCreateExecutor) RunOnce(ctx context.Context, driverCtx conte
return true, nil, err
}
- environmentID := instance.EnvironmentID
- if payload.EnvironmentId != "" {
- environmentID = payload.EnvironmentId
- }
- environment, err := exec.store.GetEnvironmentV2(ctx, &store.FindEnvironmentMessage{ResourceID: &environmentID})
- if err != nil {
- return true, nil, err
- }
// We will use schema from existing tenant databases for creating a database in a tenant mode project if possible.
- peerDatabase, peerSchemaVersion, peerSchema, err := exec.createInitialSchema(ctx, driverCtx, environment, instance, project, task, taskRunUID, database)
+ peerDatabase, peerSchemaVersion, peerSchema, err := exec.createInitialSchema(ctx, driverCtx, instance, project, task, taskRunUID, database)
if err != nil {
return true, nil, err
}
@@ -345,7 +337,7 @@ func (exec *DatabaseCreateExecutor) reconcilePlan(ctx context.Context, project *
}
}
-func (exec *DatabaseCreateExecutor) createInitialSchema(ctx context.Context, driverCtx context.Context, environment *store.EnvironmentMessage, instance *store.InstanceMessage, project *store.ProjectMessage, task *store.TaskMessage, taskRunUID int, database *store.DatabaseMessage) (*store.DatabaseMessage, string, string, error) {
+func (exec *DatabaseCreateExecutor) createInitialSchema(ctx context.Context, driverCtx context.Context, instance *store.InstanceMessage, project *store.ProjectMessage, task *store.TaskMessage, taskRunUID int, database *store.DatabaseMessage) (*store.DatabaseMessage, string, string, error) {
peerDatabase, schemaVersion, schema, err := exec.getSchemaFromPeerTenantDatabase(ctx, instance, project, database)
if err != nil {
return nil, "", "", err
@@ -366,18 +358,6 @@ func (exec *DatabaseCreateExecutor) createInitialSchema(ctx context.Context, dri
}
defer driver.Close(ctx)
- // TODO(d): support semantic versioning.
- mi := &db.MigrationInfo{
- ReleaseVersion: exec.profile.Version,
- Namespace: database.DatabaseName,
- Database: database.DatabaseName,
- DatabaseID: &database.UID,
- Environment: environment.ResourceID,
- Source: db.UI,
- Type: db.Migrate,
- Description: "Create database",
- }
-
issue, err := exec.store.GetIssueV2(ctx, &store.FindIssueMessage{PipelineID: &task.PipelineID})
if err != nil {
// If somehow we unable to find the issue, we just emit the error since it's not
@@ -401,15 +381,14 @@ func (exec *DatabaseCreateExecutor) createInitialSchema(ctx context.Context, dri
taskRunUID: taskRunUID,
taskRunName: common.FormatTaskRun(project.ResourceID, task.PipelineID, task.StageID, task.ID, taskRunUID),
version: schemaVersion,
+ migrateType: db.Migrate,
}
if issue != nil {
- mi.Description = fmt.Sprintf("%s - %s", issue.Title, task.Name)
-
mc.issueName = common.FormatIssue(issue.Project.ResourceID, issue.UID)
}
- if _, err := executeMigrationDefault(ctx, driverCtx, exec.store, exec.stateCfg, driver, mi, mc, schema, db.ExecuteOptions{}); err != nil {
+ if _, err := executeMigrationDefault(ctx, driverCtx, exec.store, exec.stateCfg, driver, mc, schema, db.ExecuteOptions{}); err != nil {
return nil, "", "", err
}
return peerDatabase, schemaVersion, schema, nil
@@ -456,7 +435,7 @@ func (exec *DatabaseCreateExecutor) getSchemaFromPeerTenantDatabase(ctx context.
// Filter out the database itself.
var databases []*store.DatabaseMessage
for _, d := range matchedDatabases {
- if d.UID != database.UID {
+ if d.String() != database.String() {
databases = append(databases, d)
}
}
diff --git a/backend/runner/taskrun/database_create_executor_test.go b/backend/runner/taskrun/database_create_executor_test.go
index f3fb8df492..b8b361ba44 100644
--- a/backend/runner/taskrun/database_create_executor_test.go
+++ b/backend/runner/taskrun/database_create_executor_test.go
@@ -11,22 +11,22 @@ import (
func TestGetPeerTenantDatabase(t *testing.T) {
dbs := []*store.DatabaseMessage{
{
- UID: 0,
+ InstanceID: "hello1",
DatabaseName: "hello",
EffectiveEnvironmentID: "dev",
},
{
- UID: 1,
+ InstanceID: "hello2",
DatabaseName: "hello2",
EffectiveEnvironmentID: "dev",
},
{
- UID: 2,
+ InstanceID: "hello3",
DatabaseName: "hello",
EffectiveEnvironmentID: "staging",
},
{
- UID: 3,
+ InstanceID: "hello4",
DatabaseName: "world",
EffectiveEnvironmentID: "prod",
},
diff --git a/backend/runner/taskrun/executor.go b/backend/runner/taskrun/executor.go
index 8e7eb3eb31..f025dd264f 100644
--- a/backend/runner/taskrun/executor.go
+++ b/backend/runner/taskrun/executor.go
@@ -5,7 +5,6 @@ import (
"fmt"
"log/slog"
"sort"
- "strings"
"time"
"github.com/pkg/errors"
@@ -87,42 +86,29 @@ type migrateContext struct {
// mutable
// changelog uid
changelog int64
+
+ migrateType db.MigrationType
+ changeHistoryPayload *storepb.InstanceChangeHistoryPayload
}
-func getMigrationInfo(ctx context.Context, stores *store.Store, profile *config.Profile, syncer *schemasync.Syncer, task *store.TaskMessage, migrationType db.MigrationType, statement string, schemaVersion string, sheetID *int, taskRunUID int, dbFactory *dbfactory.DBFactory) (*db.MigrationInfo, *migrateContext, error) {
+func getMigrationInfo(ctx context.Context, stores *store.Store, profile *config.Profile, syncer *schemasync.Syncer, task *store.TaskMessage, migrationType db.MigrationType, schemaVersion string, sheetID *int, taskRunUID int, dbFactory *dbfactory.DBFactory) (*migrateContext, error) {
instance, err := stores.GetInstanceV2(ctx, &store.FindInstanceMessage{ResourceID: &task.InstanceID})
if err != nil {
- return nil, nil, err
+ return nil, err
}
database, err := stores.GetDatabaseV2(ctx, &store.FindDatabaseMessage{InstanceID: &task.InstanceID, DatabaseName: task.DatabaseName})
if err != nil {
- return nil, nil, err
+ return nil, err
}
if database == nil {
- return nil, nil, errors.Errorf("database not found")
- }
- environment, err := stores.GetEnvironmentV2(ctx, &store.FindEnvironmentMessage{ResourceID: &database.EffectiveEnvironmentID})
- if err != nil {
- return nil, nil, err
- }
-
- mi := &db.MigrationInfo{
- DatabaseID: &database.UID,
- ReleaseVersion: profile.Version,
- Type: migrationType,
- Description: task.Name,
- Environment: environment.ResourceID,
- Database: database.DatabaseName,
- Namespace: database.DatabaseName,
- Payload: &storepb.InstanceChangeHistoryPayload{},
+ return nil, errors.Errorf("database not found")
}
-
pipeline, err := stores.GetPipelineV2ByID(ctx, task.PipelineID)
if err != nil {
- return nil, nil, errors.Wrapf(err, "failed to get pipeline")
+ return nil, errors.Wrapf(err, "failed to get pipeline")
}
if pipeline == nil {
- return nil, nil, errors.Errorf("pipeline %v not found", task.PipelineID)
+ return nil, errors.Errorf("pipeline %v not found", task.PipelineID)
}
mc := &migrateContext{
@@ -135,15 +121,16 @@ func getMigrationInfo(ctx context.Context, stores *store.Store, profile *config.
version: schemaVersion,
taskRunName: common.FormatTaskRun(pipeline.ProjectID, task.PipelineID, task.StageID, task.ID, taskRunUID),
taskRunUID: taskRunUID,
+ migrateType: migrationType,
}
if sheetID != nil {
sheet, err := stores.GetSheet(ctx, &store.FindSheetMessage{UID: sheetID})
if err != nil {
- return nil, nil, errors.Wrapf(err, "failed to get sheet")
+ return nil, errors.Wrapf(err, "failed to get sheet")
}
if sheet == nil {
- return nil, nil, errors.Errorf("sheet not found")
+ return nil, errors.Errorf("sheet not found")
}
mc.sheet = sheet
mc.sheetName = common.FormatSheet(pipeline.ProjectID, sheet.UID)
@@ -152,13 +139,13 @@ 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, nil, errors.Wrapf(err, "failed to unmarshal task payload")
+ return nil, errors.Wrapf(err, "failed to unmarshal task payload")
}
if f := p.TaskReleaseSource.GetFile(); f != "" {
project, release, _, err := common.GetProjectReleaseUIDFile(f)
if err != nil {
- return nil, nil, errors.Wrapf(err, "failed to parse file %s", f)
+ return nil, errors.Wrapf(err, "failed to parse file %s", f)
}
mc.release.release = common.FormatReleaseName(project, release)
mc.release.file = f
@@ -167,7 +154,7 @@ func getMigrationInfo(ctx context.Context, stores *store.Store, profile *config.
plans, err := stores.ListPlans(ctx, &store.FindPlanMessage{PipelineID: &task.PipelineID})
if err != nil {
- return nil, nil, errors.Wrapf(err, "failed to list plans")
+ return nil, errors.Wrapf(err, "failed to list plans")
}
if len(plans) == 1 {
planTypes := []store.PlanCheckRunType{store.PlanCheckDatabaseStatementSummaryReport}
@@ -178,7 +165,7 @@ func getMigrationInfo(ctx context.Context, stores *store.Store, profile *config.
Status: &status,
})
if err != nil {
- return nil, nil, errors.Wrap(err, "failed to list plan check runs")
+ return nil, errors.Wrap(err, "failed to list plan check runs")
}
sort.Slice(runs, func(i, j int) bool {
return runs[i].UID > runs[j].UID
@@ -190,13 +177,13 @@ func getMigrationInfo(ctx context.Context, stores *store.Store, profile *config.
}
taskInstance, err := stores.GetInstanceV2(ctx, &store.FindInstanceMessage{ResourceID: &task.InstanceID})
if err != nil {
- return nil, nil, err
+ return nil, err
}
if taskInstance == nil {
- return nil, nil, errors.Errorf("task %d instance not found", task.ID)
+ return nil, errors.Errorf("task %d instance not found", task.ID)
}
- if run.Config.InstanceUid != int32(taskInstance.UID) {
+ if run.Config.InstanceId != taskInstance.ResourceID {
continue
}
if run.Config.DatabaseName != database.DatabaseName {
@@ -213,7 +200,7 @@ func getMigrationInfo(ctx context.Context, stores *store.Store, profile *config.
continue
}
if report := result.GetSqlSummaryReport(); report != nil {
- mi.Payload.ChangedResources = report.ChangedResources
+ mc.changeHistoryPayload = &storepb.InstanceChangeHistoryPayload{ChangedResources: report.ChangedResources}
foundChangedResources = true
break
}
@@ -226,21 +213,9 @@ func getMigrationInfo(ctx context.Context, stores *store.Store, profile *config.
slog.Error("failed to find containing issue", log.BBError(err))
}
if issue != nil {
- // Concat issue title and task name as the migration description so that user can see
- // more context of the migration.
- mi.Description = fmt.Sprintf("%s - %s", issue.Title, task.Name)
-
mc.issueName = common.FormatIssue(issue.Project.ResourceID, issue.UID)
}
-
- mi.Source = db.UI
-
- statement = strings.TrimSpace(statement)
- // Only baseline and SDL migration can have empty sql statement, which indicates empty database.
- if mi.Type != db.Baseline && mi.Type != db.MigrateSDL && statement == "" {
- return nil, nil, errors.Errorf("empty statement")
- }
- return mi, mc, nil
+ return mc, nil
}
func getCreateTaskRunLog(ctx context.Context, taskRunUID int, s *store.Store, profile *config.Profile) func(t time.Time, e *storepb.TaskRunLog) error {
@@ -274,7 +249,6 @@ func doMigration(
stateCfg *state.State,
profile *config.Profile,
statement string,
- mi *db.MigrationInfo,
mc *migrateContext,
) (bool, error) {
instance := mc.instance
@@ -296,8 +270,7 @@ func doMigration(
slog.Debug("Start migration...",
slog.String("instance", instance.ResourceID),
slog.String("database", database.DatabaseName),
- slog.String("source", string(mi.Source)),
- slog.String("type", string(mi.Type)),
+ slog.String("type", string(mc.migrateType)),
slog.String("statement", statementRecord),
)
@@ -326,10 +299,10 @@ func doMigration(
}
}
- return executeMigrationDefault(ctx, driverCtx, stores, stateCfg, driver, mi, mc, statement, opts)
+ return executeMigrationDefault(ctx, driverCtx, stores, stateCfg, driver, mc, statement, opts)
}
-func postMigration(ctx context.Context, stores *store.Store, mi *db.MigrationInfo, mc *migrateContext, skipped bool) (bool, *storepb.TaskRunResult, error) {
+func postMigration(ctx context.Context, stores *store.Store, mc *migrateContext, skipped bool) (bool, *storepb.TaskRunResult, error) {
if skipped {
return true, &storepb.TaskRunResult{
Detail: fmt.Sprintf("Task skipped because version %s has been applied", mc.version),
@@ -358,7 +331,7 @@ func postMigration(ctx context.Context, stores *store.Store, mi *db.MigrationInf
}
detail := fmt.Sprintf("Applied migration version %s to database %q.", mc.version, database.DatabaseName)
- if mi.Type == db.Baseline {
+ if mc.migrateType == db.Baseline {
detail = fmt.Sprintf("Established baseline version %s for database %q.", mc.version, database.DatabaseName)
}
@@ -370,34 +343,34 @@ func postMigration(ctx context.Context, stores *store.Store, mi *db.MigrationInf
}
func runMigration(ctx context.Context, driverCtx context.Context, store *store.Store, dbFactory *dbfactory.DBFactory, stateCfg *state.State, syncer *schemasync.Syncer, profile *config.Profile, task *store.TaskMessage, taskRunUID int, migrationType db.MigrationType, statement string, schemaVersion string, sheetID *int) (terminated bool, result *storepb.TaskRunResult, err error) {
- mi, mc, err := getMigrationInfo(ctx, store, profile, syncer, task, migrationType, statement, schemaVersion, sheetID, taskRunUID, dbFactory)
+ mc, err := getMigrationInfo(ctx, store, profile, syncer, task, migrationType, schemaVersion, sheetID, taskRunUID, dbFactory)
if err != nil {
return true, nil, err
}
- skipped, err := doMigration(ctx, driverCtx, store, stateCfg, profile, statement, mi, mc)
+ skipped, err := doMigration(ctx, driverCtx, store, stateCfg, profile, statement, mc)
if err != nil {
return true, nil, err
}
- return postMigration(ctx, store, mi, mc, skipped)
+ return postMigration(ctx, store, mc, skipped)
}
// executeMigrationDefault executes migration.
-func executeMigrationDefault(ctx context.Context, driverCtx context.Context, store *store.Store, _ *state.State, driver db.Driver, mi *db.MigrationInfo, mc *migrateContext, statement string, opts db.ExecuteOptions) (skipped bool, resErr error) {
+func executeMigrationDefault(ctx context.Context, driverCtx context.Context, store *store.Store, _ *state.State, driver db.Driver, mc *migrateContext, statement string, opts db.ExecuteOptions) (skipped bool, resErr error) {
execFunc := func(ctx context.Context, execStatement string) error {
if _, err := driver.Execute(ctx, execStatement, opts); err != nil {
return err
}
return nil
}
- return executeMigrationWithFunc(ctx, driverCtx, store, mi, mc, statement, execFunc, opts)
+ return executeMigrationWithFunc(ctx, driverCtx, store, mc, statement, execFunc, opts)
}
// executeMigrationWithFunc executes the migration with custom migration function.
-func executeMigrationWithFunc(ctx context.Context, driverCtx context.Context, s *store.Store, mi *db.MigrationInfo, mc *migrateContext, statement string, execFunc func(ctx context.Context, execStatement string) error, opts db.ExecuteOptions) (skipped bool, resErr error) {
+func executeMigrationWithFunc(ctx context.Context, driverCtx context.Context, s *store.Store, mc *migrateContext, statement string, execFunc func(ctx context.Context, execStatement string) error, opts db.ExecuteOptions) (skipped bool, resErr error) {
// Phase 1 - Dump before migration.
// Check if versioned is already applied.
- skipExecution, err := beginMigration(ctx, s, mi, mc, opts)
+ skipExecution, err := beginMigration(ctx, s, mc, opts)
if err != nil {
return false, errors.Wrapf(err, "failed to begin migration")
}
@@ -408,7 +381,7 @@ func executeMigrationWithFunc(ctx context.Context, driverCtx context.Context, s
defer func() {
// Phase 3 - Dump after migration.
// Insert revision for versioned.
- if err := endMigration(ctx, s, mi, mc, resErr == nil /* isDone */); err != nil {
+ if err := endMigration(ctx, s, mc, resErr == nil /* isDone */); err != nil {
slog.Error("failed to end migration",
log.BBError(err),
)
@@ -416,31 +389,10 @@ func executeMigrationWithFunc(ctx context.Context, driverCtx context.Context, s
}()
// Phase 2 - Executing migration.
- // Branch migration type always has empty sql.
- // Baseline migration type could has non-empty sql but will not execute.
- // https://github.com/bytebase/bytebase/issues/394
- doMigrate := true
- if statement == "" || mi.Type == db.Baseline {
- doMigrate = false
- }
- if doMigrate {
- renderedStatement := statement
- // The m.DatabaseID is nil means the migration is a instance level migration
- if mi.DatabaseID != nil {
- database, err := s.GetDatabaseV2(ctx, &store.FindDatabaseMessage{
- UID: mi.DatabaseID,
- })
- if err != nil {
- return false, err
- }
- if database == nil {
- return false, errors.Errorf("database %d not found", *mi.DatabaseID)
- }
- materials := utils.GetSecretMapFromDatabaseMessage(database)
- // To avoid leak the rendered statement, the error message should use the original statement and not the rendered statement.
- renderedStatement = utils.RenderStatement(statement, materials)
- }
-
+ if mc.migrateType != db.Baseline {
+ materials := utils.GetSecretMapFromDatabaseMessage(mc.database)
+ // To avoid leak the rendered statement, the error message should use the original statement and not the rendered statement.
+ renderedStatement := utils.RenderStatement(statement, materials)
if err := execFunc(driverCtx, renderedStatement); err != nil {
return false, err
}
@@ -450,7 +402,7 @@ func executeMigrationWithFunc(ctx context.Context, driverCtx context.Context, s
}
// beginMigration checks before executing migration and inserts a migration history record with pending status.
-func beginMigration(ctx context.Context, stores *store.Store, mi *db.MigrationInfo, mc *migrateContext, opts db.ExecuteOptions) (bool, error) {
+func beginMigration(ctx context.Context, stores *store.Store, mc *migrateContext, opts db.ExecuteOptions) (bool, error) {
// list revisions and see if it has been applied
// we can do this because
// versioned migrations are executed one by one
@@ -477,7 +429,7 @@ func beginMigration(ctx context.Context, stores *store.Store, mi *db.MigrationIn
// sync history
var syncHistoryPrevUID *int64
- if mi.Type.NeedDump() {
+ if mc.migrateType.NeedDump() {
opts.LogDatabaseSyncStart()
syncHistoryPrev, err := mc.syncer.SyncDatabaseSchemaToHistory(ctx, mc.database, false)
if err != nil {
@@ -499,7 +451,7 @@ func beginMigration(ctx context.Context, stores *store.Store, mi *db.MigrationIn
TaskRun: mc.taskRunName,
Issue: mc.issueName,
Revision: 0,
- ChangedResources: mi.Payload.GetChangedResources(),
+ ChangedResources: mc.changeHistoryPayload.GetChangedResources(),
Sheet: mc.sheetName,
Version: mc.version,
Type: convertTaskType(mc.task.Type),
@@ -513,12 +465,12 @@ func beginMigration(ctx context.Context, stores *store.Store, mi *db.MigrationIn
}
// endMigration updates the migration history record to DONE or FAILED depending on migration is done or not.
-func endMigration(ctx context.Context, storeInstance *store.Store, mi *db.MigrationInfo, mc *migrateContext, isDone bool) error {
+func endMigration(ctx context.Context, storeInstance *store.Store, mc *migrateContext, isDone bool) error {
update := &store.UpdateChangelogMessage{
UID: mc.changelog,
}
- if mi.Type.NeedDump() {
+ if mc.migrateType.NeedDump() {
syncHistory, err := mc.syncer.SyncDatabaseSchemaToHistory(ctx, mc.database, false)
if err != nil {
return errors.Wrapf(err, "failed to sync database metadata and schema")
diff --git a/backend/runner/taskrun/schema_update_ghost_cutover_executor.go b/backend/runner/taskrun/schema_update_ghost_cutover_executor.go
index dfcec084eb..fb74e0848e 100644
--- a/backend/runner/taskrun/schema_update_ghost_cutover_executor.go
+++ b/backend/runner/taskrun/schema_update_ghost_cutover_executor.go
@@ -21,7 +21,6 @@ import (
"github.com/bytebase/bytebase/backend/plugin/db"
"github.com/bytebase/bytebase/backend/runner/schemasync"
"github.com/bytebase/bytebase/backend/store"
- "github.com/bytebase/bytebase/backend/utils"
storepb "github.com/bytebase/bytebase/proto/generated-go/store"
)
@@ -78,16 +77,8 @@ func (e *SchemaUpdateGhostCutoverExecutor) RunOnce(ctx context.Context, taskCont
if err != nil {
return true, nil, errors.Wrapf(err, "failed to get sheet statement by id: %d", sheetID)
}
- materials := utils.GetSecretMapFromDatabaseMessage(database)
- // To avoid leaking the rendered statement, the error message should use the original statement and not the rendered statement.
- renderedStatement := utils.RenderStatement(statement, materials)
- tableName, err := ghost.GetTableNameFromStatement(renderedStatement)
- if err != nil {
- return true, nil, common.Wrapf(err, common.Internal, "failed to parse table name from statement, statement: %v", statement)
- }
-
- postponeFilename := ghost.GetPostponeFlagFilename(syncTaskID, database.UID, database.DatabaseName, tableName)
+ postponeFilename := ghost.GetPostponeFlagFilename(syncTaskID)
value, ok := e.stateCfg.GhostTaskState.Load(syncTaskID)
if !ok {
@@ -121,7 +112,7 @@ func cutover(ctx context.Context, taskContext context.Context, stores *store.Sto
return true, nil, err
}
- mi, mc, err := getMigrationInfo(ctx, stores, profile, syncer, task, db.Migrate, statement, schemaVersion, &sheetID, taskRunUID, dbFactory)
+ mc, err := getMigrationInfo(ctx, stores, profile, syncer, task, db.Migrate, schemaVersion, &sheetID, taskRunUID, dbFactory)
if err != nil {
return true, nil, err
}
@@ -138,12 +129,12 @@ func cutover(ctx context.Context, taskContext context.Context, stores *store.Sto
// TODO(p0ny): we may need to defer execFunc to do the cleanup always.
// And we might want to move the check that determines if the task should be skipped
// to the sync executor.
- skipped, err := executeMigrationWithFunc(ctx, ctx, stores, mi, mc, statement, execFunc, db.ExecuteOptions{})
+ skipped, err := executeMigrationWithFunc(ctx, ctx, stores, mc, statement, execFunc, db.ExecuteOptions{})
if err != nil {
return true, nil, err
}
- return postMigration(ctx, stores, mi, mc, skipped)
+ return postMigration(ctx, stores, mc, skipped)
}
func waitForCutover(ctx context.Context, taskContext context.Context, migrationContext *base.MigrationContext) bool {
diff --git a/backend/server/onboard.go b/backend/server/onboard.go
index d25a668558..3f4aee416b 100644
--- a/backend/server/onboard.go
+++ b/backend/server/onboard.go
@@ -304,7 +304,7 @@ func (s *Server) generateOnboardingData(ctx context.Context, user *store.UserMes
// experience the sensitive data masking feature from SQL Editor.
dbSchema, err := s.store.GetDBSchema(ctx, prodDatabase.InstanceID, prodDatabase.DatabaseName)
if err != nil {
- return errors.Wrapf(err, "failed to get db schema for database %v", prodDatabase.UID)
+ return errors.Wrapf(err, "failed to get db schema for database %s", prodDatabase.String())
}
dbModelConfig := model.NewDatabaseConfig(nil)
if dbSchema != nil {
@@ -316,7 +316,7 @@ func (s *Server) generateOnboardingData(ctx context.Context, user *store.UserMes
columnConfig.SemanticType = "default"
if err := s.store.UpdateDBSchema(ctx, prodDatabase.InstanceID, prodDatabase.DatabaseName, &store.UpdateDBSchemaMessage{Config: dbModelConfig.BuildDatabaseConfig()}); err != nil {
- return errors.Wrapf(err, "failed to update db config for database %v", prodDatabase.UID)
+ return errors.Wrapf(err, "failed to update db config for database %v", prodDatabase.String())
}
return nil
diff --git a/backend/store/data_source.go b/backend/store/data_source.go
index 155905ae8b..b7522dfc2b 100644
--- a/backend/store/data_source.go
+++ b/backend/store/data_source.go
@@ -106,7 +106,6 @@ func (m *DataSourceMessage) Copy() *DataSourceMessage {
// UpdateDataSourceMessage is the message for the data source.
type UpdateDataSourceMessage struct {
- InstanceUID int
InstanceID string
DataSourceID string
@@ -278,7 +277,7 @@ func (s *Store) GetDataSource(ctx context.Context, find *FindDataSourceMessage)
}
// AddDataSourceToInstanceV2 adds a RO data source to an instance and return the instance where the data source is added.
-func (s *Store) AddDataSourceToInstanceV2(ctx context.Context, instanceUID int, instanceID string, dataSource *DataSourceMessage) error {
+func (s *Store) AddDataSourceToInstanceV2(ctx context.Context, instanceID string, dataSource *DataSourceMessage) error {
tx, err := s.db.BeginTx(ctx, nil)
if err != nil {
return errors.New("Failed to begin transaction")
@@ -294,12 +293,11 @@ func (s *Store) AddDataSourceToInstanceV2(ctx context.Context, instanceUID int,
}
s.instanceCache.Remove(getInstanceCacheKey(instanceID))
- s.instanceIDCache.Remove(instanceUID)
return nil
}
// RemoveDataSourceV2 removes a RO data source from an instance.
-func (s *Store) RemoveDataSourceV2(ctx context.Context, instanceUID int, instanceID string, dataSourceID string) error {
+func (s *Store) RemoveDataSourceV2(ctx context.Context, instanceID string, dataSourceID string) error {
tx, err := s.db.BeginTx(ctx, nil)
if err != nil {
return errors.New("Failed to begin transaction")
@@ -318,7 +316,7 @@ func (s *Store) RemoveDataSourceV2(ctx context.Context, instanceUID int, instanc
return errors.Wrapf(err, "failed to get rows affected")
}
if rowsAffected != 1 {
- return errors.Errorf("remove %d type data_sources for instance uid %d, but expected 1", rowsAffected, instanceUID)
+ return errors.Errorf("remove %d type data_sources for instance %s, but expected 1", rowsAffected, instanceID)
}
if err := tx.Commit(); err != nil {
@@ -326,7 +324,6 @@ func (s *Store) RemoveDataSourceV2(ctx context.Context, instanceUID int, instanc
}
s.instanceCache.Remove(getInstanceCacheKey(instanceID))
- s.instanceIDCache.Remove(instanceUID)
return nil
}
@@ -472,7 +469,7 @@ func (s *Store) UpdateDataSourceV2(ctx context.Context, patch *UpdateDataSourceM
return errors.Wrapf(err, "failed to get rows affected")
}
if rowsAffected != 1 {
- return errors.Errorf("update %v data source records from instance %v, but expected one", rowsAffected, patch.InstanceUID)
+ return errors.Errorf("update %v data source records from instance %s, but expected one", rowsAffected, patch.InstanceID)
}
if err := tx.Commit(); err != nil {
@@ -480,7 +477,6 @@ func (s *Store) UpdateDataSourceV2(ctx context.Context, patch *UpdateDataSourceM
}
s.instanceCache.Remove(getInstanceCacheKey(patch.InstanceID))
- s.instanceIDCache.Remove(patch.InstanceUID)
return nil
}
diff --git a/backend/store/database.go b/backend/store/database.go
index 92fce5d968..60da3d9839 100644
--- a/backend/store/database.go
+++ b/backend/store/database.go
@@ -17,17 +17,17 @@ import (
// DatabaseMessage is the message for database.
type DatabaseMessage struct {
- UID int
- ProjectID string
- InstanceID string
+ ProjectID string
+ InstanceID string
+ DatabaseName string
+
EnvironmentID string
EffectiveEnvironmentID string
- DatabaseName string
- SyncState api.SyncStatus
- SyncAt time.Time
- Secrets *storepb.Secrets
- DataShare bool
+ SyncState api.SyncStatus
+ SyncAt time.Time
+ Secrets *storepb.Secrets
+ DataShare bool
// ServiceName is the Oracle specific field.
ServiceName string
Metadata *storepb.DatabaseMetadata
@@ -35,6 +35,10 @@ type DatabaseMessage struct {
SchemaVersion string
}
+func (d *DatabaseMessage) String() string {
+ return common.FormatDatabase(d.InstanceID, d.DatabaseName)
+}
+
// UpdateDatabaseMessage is the mssage for updating a database.
type UpdateDatabaseMessage struct {
InstanceID string
@@ -60,7 +64,6 @@ type FindDatabaseMessage struct {
EffectiveEnvironmentID *string
InstanceID *string
DatabaseName *string
- UID *int
Engine *storepb.Engine
// When this is used, we will return databases from archived instances or environments.
// This is used for existing tasks with archived databases.
@@ -80,11 +83,6 @@ func (s *Store) GetDatabaseV2(ctx context.Context, find *FindDatabaseMessage) (*
return v, nil
}
}
- if find.UID != nil {
- if v, ok := s.databaseIDCache.Get(*find.UID); ok {
- return v, nil
- }
- }
tx, err := s.db.BeginTx(ctx, &sql.TxOptions{ReadOnly: true})
if err != nil {
@@ -109,7 +107,6 @@ func (s *Store) GetDatabaseV2(ctx context.Context, find *FindDatabaseMessage) (*
}
s.databaseCache.Add(getDatabaseCacheKey(database.InstanceID, database.DatabaseName), database)
- s.databaseIDCache.Add(database.UID, database)
return database, nil
}
@@ -132,7 +129,6 @@ func (s *Store) ListDatabases(ctx context.Context, find *FindDatabaseMessage) ([
for _, database := range databases {
s.databaseCache.Add(getDatabaseCacheKey(database.InstanceID, database.DatabaseName), database)
- s.databaseIDCache.Add(database.UID, database)
}
return databases, nil
}
@@ -145,8 +141,7 @@ func (s *Store) CreateDatabaseDefault(ctx context.Context, create *DatabaseMessa
}
defer tx.Rollback()
- databaseUID, err := s.createDatabaseDefaultImpl(ctx, tx, create.ProjectID, create.InstanceID, create)
- if err != nil {
+ if _, err := s.createDatabaseDefaultImpl(ctx, tx, create.ProjectID, create.InstanceID, create); err != nil {
return nil, err
}
@@ -156,8 +151,7 @@ func (s *Store) CreateDatabaseDefault(ctx context.Context, create *DatabaseMessa
// Invalidate an update the cache.
s.databaseCache.Remove(getDatabaseCacheKey(create.InstanceID, create.DatabaseName))
- s.databaseIDCache.Remove(databaseUID)
- return s.GetDatabaseV2(ctx, &FindDatabaseMessage{UID: &databaseUID})
+ return s.GetDatabaseV2(ctx, &FindDatabaseMessage{InstanceID: &create.InstanceID, DatabaseName: &create.DatabaseName, ShowDeleted: true})
}
// createDatabaseDefault only creates a default database with charset, collation only in the default project.
@@ -269,8 +263,7 @@ func (s *Store) UpsertDatabase(ctx context.Context, create *DatabaseMessage) (*D
// Invalidate and update the cache.
s.databaseCache.Remove(getDatabaseCacheKey(create.InstanceID, create.DatabaseName))
- s.databaseIDCache.Remove(databaseUID)
- return s.GetDatabaseV2(ctx, &FindDatabaseMessage{UID: &databaseUID, ShowDeleted: true})
+ return s.GetDatabaseV2(ctx, &FindDatabaseMessage{InstanceID: &create.InstanceID, DatabaseName: &create.DatabaseName, ShowDeleted: true})
}
// UpdateDatabase updates a database.
@@ -342,8 +335,7 @@ func (s *Store) UpdateDatabase(ctx context.Context, patch *UpdateDatabaseMessage
// Invalidate and update database cache.
s.databaseCache.Remove(getDatabaseCacheKey(patch.InstanceID, patch.DatabaseName))
- s.databaseIDCache.Remove(databaseUID)
- return s.GetDatabaseV2(ctx, &FindDatabaseMessage{UID: &databaseUID, ShowDeleted: true})
+ return s.GetDatabaseV2(ctx, &FindDatabaseMessage{InstanceID: &patch.InstanceID, DatabaseName: &patch.DatabaseName, ShowDeleted: true})
}
// BatchUpdateDatabaseProject updates the project for databases in batch.
@@ -382,7 +374,6 @@ func (s *Store) BatchUpdateDatabaseProject(ctx context.Context, databases []*Dat
updatedDatabase := *database
updatedDatabase.ProjectID = projectID
s.databaseCache.Add(getDatabaseCacheKey(database.InstanceID, database.DatabaseName), &updatedDatabase)
- s.databaseIDCache.Add(database.UID, &updatedDatabase)
updatedDatabases = append(updatedDatabases, &updatedDatabase)
}
return updatedDatabases, nil
@@ -410,9 +401,6 @@ func (*Store) listDatabaseImplV2(ctx context.Context, tx *Tx, find *FindDatabase
where, args = append(where, fmt.Sprintf("db.name = $%d", len(args)+1)), append(args, *v)
}
}
- if v := find.UID; v != nil {
- where, args = append(where, fmt.Sprintf("db.id = $%d", len(args)+1)), append(args, *v)
- }
if v := find.Engine; v != nil {
where, args = append(where, fmt.Sprintf("instance.engine = $%d", len(args)+1)), append(args, *v)
}
@@ -435,7 +423,6 @@ func (*Store) listDatabaseImplV2(ctx context.Context, tx *Tx, find *FindDatabase
query := fmt.Sprintf(`
SELECT
- db.id,
db.project,
COALESCE(
(SELECT environment.resource_id FROM environment WHERE environment.resource_id = db.environment),
@@ -484,7 +471,6 @@ func (*Store) listDatabaseImplV2(ctx context.Context, tx *Tx, find *FindDatabase
var secretsString, metadataString string
var effectiveEnvironment, environment sql.NullString
if err := rows.Scan(
- &databaseMessage.UID,
&databaseMessage.ProjectID,
&effectiveEnvironment,
&environment,
diff --git a/backend/store/instance.go b/backend/store/instance.go
index f32224f28d..473fb5adf6 100644
--- a/backend/store/instance.go
+++ b/backend/store/instance.go
@@ -27,7 +27,6 @@ type InstanceMessage struct {
Activation bool
Options *storepb.InstanceOptions
EnvironmentID string
- UID int
Deleted bool
EngineVersion string
Metadata *storepb.InstanceMetadata
@@ -52,7 +51,6 @@ type UpdateInstanceMessage struct {
// FindInstanceMessage is the message for finding instances.
type FindInstanceMessage struct {
- UID *int
ResourceID *string
ResourceIDs *[]string
ShowDeleted bool
@@ -65,11 +63,6 @@ func (s *Store) GetInstanceV2(ctx context.Context, find *FindInstanceMessage) (*
return v, nil
}
}
- if find.UID != nil {
- if v, ok := s.instanceIDCache.Get(*find.UID); ok {
- return v, nil
- }
- }
// We will always return the resource regardless of its deleted state.
find.ShowDeleted = true
@@ -95,7 +88,6 @@ func (s *Store) GetInstanceV2(ctx context.Context, find *FindInstanceMessage) (*
instance := instances[0]
s.instanceCache.Add(getInstanceCacheKey(instance.ResourceID), instance)
- s.instanceIDCache.Add(instance.UID, instance)
return instance, nil
}
@@ -118,7 +110,6 @@ func (s *Store) ListInstancesV2(ctx context.Context, find *FindInstanceMessage)
for _, instance := range instances {
s.instanceCache.Add(getInstanceCacheKey(instance.ResourceID), instance)
- s.instanceIDCache.Add(instance.UID, instance)
}
return instances, nil
}
@@ -202,7 +193,6 @@ func (s *Store) CreateInstanceV2(ctx context.Context, instanceCreate *InstanceMe
instance := &InstanceMessage{
EnvironmentID: instanceCreate.EnvironmentID,
ResourceID: instanceCreate.ResourceID,
- UID: instanceID,
Title: instanceCreate.Title,
Engine: instanceCreate.Engine,
ExternalLink: instanceCreate.ExternalLink,
@@ -212,7 +202,6 @@ func (s *Store) CreateInstanceV2(ctx context.Context, instanceCreate *InstanceMe
Metadata: instanceCreate.Metadata,
}
s.instanceCache.Add(getInstanceCacheKey(instance.ResourceID), instance)
- s.instanceIDCache.Add(instance.UID, instance)
return instance, nil
}
@@ -287,7 +276,6 @@ func (s *Store) UpdateInstanceV2(ctx context.Context, patch *UpdateInstanceMessa
SET `+strings.Join(set, ", ")+`
WHERE %s
RETURNING
- id,
resource_id,
environment,
name,
@@ -302,7 +290,6 @@ func (s *Store) UpdateInstanceV2(ctx context.Context, patch *UpdateInstanceMessa
var environment sql.NullString
var options, metadata []byte
if err := tx.QueryRowContext(ctx, query, args...).Scan(
- &instance.UID,
&instance.ResourceID,
&environment,
&instance.Title,
@@ -371,7 +358,6 @@ func (s *Store) UpdateInstanceV2(ctx context.Context, patch *UpdateInstanceMessa
}
s.instanceCache.Add(getInstanceCacheKey(instance.ResourceID), instance)
- s.instanceIDCache.Add(instance.UID, instance)
return instance, nil
}
@@ -383,9 +369,6 @@ func (s *Store) listInstanceImplV2(ctx context.Context, tx *Tx, find *FindInstan
if v := find.ResourceIDs; v != nil {
where, args = append(where, fmt.Sprintf("instance.resource_id = ANY($%d)", len(args)+1)), append(args, *v)
}
- if v := find.UID; v != nil {
- where, args = append(where, fmt.Sprintf("instance.id = $%d", len(args)+1)), append(args, *v)
- }
if !find.ShowDeleted {
where, args = append(where, fmt.Sprintf("instance.deleted = $%d", len(args)+1)), append(args, false)
}
@@ -393,7 +376,6 @@ func (s *Store) listInstanceImplV2(ctx context.Context, tx *Tx, find *FindInstan
var instanceMessages []*InstanceMessage
rows, err := tx.QueryContext(ctx, fmt.Sprintf(`
SELECT
- id,
resource_id,
name,
environment,
@@ -419,7 +401,6 @@ func (s *Store) listInstanceImplV2(ctx context.Context, tx *Tx, find *FindInstan
var engine string
var options, metadata []byte
if err := rows.Scan(
- &instanceMessage.UID,
&instanceMessage.ResourceID,
&instanceMessage.Title,
&environment,
diff --git a/backend/store/store.go b/backend/store/store.go
index 6b59a821cc..561b6e58a3 100644
--- a/backend/store/store.go
+++ b/backend/store/store.go
@@ -22,9 +22,7 @@ type Store struct {
userEmailCache *lru.Cache[string, *UserMessage]
environmentCache *lru.Cache[string, *EnvironmentMessage]
instanceCache *lru.Cache[string, *InstanceMessage]
- instanceIDCache *lru.Cache[int, *InstanceMessage]
databaseCache *lru.Cache[string, *DatabaseMessage]
- databaseIDCache *lru.Cache[int, *DatabaseMessage]
projectCache *lru.Cache[string, *ProjectMessage]
projectDeploymentCache *lru.Cache[string, *DeploymentConfigMessage]
policyCache *lru.Cache[string, *PolicyMessage]
@@ -35,7 +33,7 @@ type Store struct {
idpCache *lru.Cache[string, *IdentityProviderMessage]
risksCache *lru.Cache[int, []*RiskMessage] // Use 0 as the key.
databaseGroupCache *lru.Cache[string, *DatabaseGroupMessage]
- vcsIDCache *lru.Cache[string, *VCSProviderMessage]
+ vcsCache *lru.Cache[string, *VCSProviderMessage]
rolesCache *lru.Cache[string, *RoleMessage]
groupCache *lru.Cache[string, *GroupMessage]
sheetCache *lru.Cache[int, *SheetMessage]
@@ -63,18 +61,10 @@ func New(db *DB, profile *config.Profile) (*Store, error) {
if err != nil {
return nil, err
}
- instanceIDCache, err := lru.New[int, *InstanceMessage](32768)
- if err != nil {
- return nil, err
- }
databaseCache, err := lru.New[string, *DatabaseMessage](32768)
if err != nil {
return nil, err
}
- databaseIDCache, err := lru.New[int, *DatabaseMessage](32768)
- if err != nil {
- return nil, err
- }
projectCache, err := lru.New[string, *ProjectMessage](32768)
if err != nil {
return nil, err
@@ -149,9 +139,7 @@ func New(db *DB, profile *config.Profile) (*Store, error) {
userEmailCache: userEmailCache,
environmentCache: environmentCache,
instanceCache: instanceCache,
- instanceIDCache: instanceIDCache,
databaseCache: databaseCache,
- databaseIDCache: databaseIDCache,
projectCache: projectCache,
projectDeploymentCache: projectDeploymentCache,
policyCache: policyCache,
@@ -162,7 +150,7 @@ func New(db *DB, profile *config.Profile) (*Store, error) {
idpCache: idpCache,
risksCache: risksCache,
databaseGroupCache: databaseGroupCache,
- vcsIDCache: vcsIDCache,
+ vcsCache: vcsIDCache,
rolesCache: rolesCache,
sheetCache: sheetCache,
sheetStatementCache: sheetStatementCache,
diff --git a/backend/store/vcs_provider.go b/backend/store/vcs_provider.go
index c04b6fee24..542b739e28 100644
--- a/backend/store/vcs_provider.go
+++ b/backend/store/vcs_provider.go
@@ -40,7 +40,7 @@ type FindVCSProviderMessage struct {
// GetVCSProvider gets an VCS provider by ID.
func (s *Store) GetVCSProvider(ctx context.Context, find *FindVCSProviderMessage) (*VCSProviderMessage, error) {
if find.ResourceID != nil {
- if v, ok := s.vcsIDCache.Get(*find.ResourceID); ok {
+ if v, ok := s.vcsCache.Get(*find.ResourceID); ok {
return v, nil
}
}
@@ -65,7 +65,7 @@ func (s *Store) GetVCSProvider(ctx context.Context, find *FindVCSProviderMessage
}
vcs := vcsProviders[0]
- s.vcsIDCache.Add(vcs.ResourceID, vcs)
+ s.vcsCache.Add(vcs.ResourceID, vcs)
return vcs, nil
}
@@ -86,7 +86,7 @@ func (s *Store) ListVCSProviders(ctx context.Context) ([]*VCSProviderMessage, er
}
for _, vcs := range vcsProviders {
- s.vcsIDCache.Add(vcs.ResourceID, vcs)
+ s.vcsCache.Add(vcs.ResourceID, vcs)
}
return vcsProviders, nil
}
@@ -124,7 +124,7 @@ func (s *Store) CreateVCSProvider(ctx context.Context, create *VCSProviderMessag
return nil, errors.Wrapf(err, "failed to commit transaction")
}
- s.vcsIDCache.Add(create.ResourceID, create)
+ s.vcsCache.Add(create.ResourceID, create)
return create, nil
}
@@ -172,7 +172,7 @@ func (s *Store) UpdateVCSProvider(ctx context.Context, vcsProviderID string, upd
if err := tx.Commit(); err != nil {
return nil, errors.Wrapf(err, "failed to commit transaction")
}
- s.vcsIDCache.Add(vcsProvider.ResourceID, &vcsProvider)
+ s.vcsCache.Add(vcsProvider.ResourceID, &vcsProvider)
return &vcsProvider, nil
}
@@ -192,7 +192,7 @@ func (s *Store) DeleteVCSProvider(ctx context.Context, vcsProviderID string) err
return errors.Wrapf(err, "failed to commit transaction")
}
- s.vcsIDCache.Remove(vcsProviderID)
+ s.vcsCache.Remove(vcsProviderID)
return nil
}
diff --git a/backend/tests/ghost_test.go b/backend/tests/ghost_test.go
index 833cd7329e..133edbb980 100644
--- a/backend/tests/ghost_test.go
+++ b/backend/tests/ghost_test.go
@@ -8,14 +8,12 @@ import (
"fmt"
"regexp"
"strconv"
- "strings"
"testing"
"github.com/bytebase/bytebase/backend/resources/mysql"
"github.com/bytebase/bytebase/backend/tests/fake"
v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"
- ghostsql "github.com/github/gh-ost/go/sql"
_ "github.com/go-sql-driver/mysql"
"github.com/stretchr/testify/require"
)
@@ -42,29 +40,6 @@ var (
deletedRegex = regexp.MustCompile("~book_[0-9]+_del")
)
-func TestGhostParser(t *testing.T) {
- t.Parallel()
- a := require.New(t)
- const statement = `
- ALTER TABLE
- test
- ADD
- COLUMN ghost_play_2 int;
- `
- t.Run("fail to parse", func(t *testing.T) {
- t.Parallel()
- parser := ghostsql.NewParserFromAlterStatement(statement)
- a.Equal(false, parser.HasExplicitTable())
- })
- t.Run("succeed to parse", func(t *testing.T) {
- t.Parallel()
- s := strings.Join(strings.Fields(statement), " ")
- parser := ghostsql.NewParserFromAlterStatement(s)
- a.Equal(true, parser.HasExplicitTable())
- a.Equal("test", parser.GetExplicitTable())
- })
-}
-
func TestGhostSchemaUpdate(t *testing.T) {
const databaseName = "testGhostSchemaUpdate"
diff --git a/backend/utils/utils.go b/backend/utils/utils.go
index 4325de0cfe..b431445510 100644
--- a/backend/utils/utils.go
+++ b/backend/utils/utils.go
@@ -125,31 +125,31 @@ func ValidateDeploymentSchedule(schedule *storepb.Schedule) error {
func GetDatabaseMatrixFromDeploymentSchedule(schedule *storepb.Schedule, databaseList []*store.DatabaseMessage) ([][]*store.DatabaseMessage, error) {
var matrix [][]*store.DatabaseMessage
- // idToLabels maps databaseID -> label key -> label value
- idToLabels := make(map[int]map[string]string)
- databaseMap := make(map[int]*store.DatabaseMessage)
+ // idToLabels maps database -> label key -> label value
+ idToLabels := make(map[string]map[string]string)
+ databaseMap := make(map[string]*store.DatabaseMessage)
for _, database := range databaseList {
- databaseMap[database.UID] = database
+ databaseMap[database.String()] = database
newMap := make(map[string]string)
for k, v := range database.Metadata.Labels {
newMap[k] = v
}
newMap[api.EnvironmentLabelKey] = database.EffectiveEnvironmentID
- idToLabels[database.UID] = newMap
+ idToLabels[database.String()] = newMap
}
- // idsSeen records database id which is already in a stage.
- idsSeen := make(map[int]bool)
+ // idsSeen records database which is already in a stage.
+ idsSeen := make(map[string]bool)
// For each stage, we loop over all databases to see if it is a match.
for _, deployment := range schedule.Deployments {
// For each stage, we will get a list of matched databases.
- var matchedDatabaseList []int
+ var matchedDatabaseList []string
// Loop over databaseList instead of idToLabels to get determinant results.
for _, database := range databaseList {
// Skip if the database is already in a stage.
- if _, ok := idsSeen[database.UID]; ok {
+ if _, ok := idsSeen[database.String()]; ok {
continue
}
// Skip if the database is not found.
@@ -157,9 +157,9 @@ func GetDatabaseMatrixFromDeploymentSchedule(schedule *storepb.Schedule, databas
continue
}
- if isMatchExpressions(idToLabels[database.UID], deployment.Spec.Selector.MatchExpressions) {
- matchedDatabaseList = append(matchedDatabaseList, database.UID)
- idsSeen[database.UID] = true
+ if isMatchExpressions(idToLabels[database.String()], deployment.Spec.Selector.MatchExpressions) {
+ matchedDatabaseList = append(matchedDatabaseList, database.String())
+ idsSeen[database.String()] = true
}
}
@@ -167,10 +167,10 @@ func GetDatabaseMatrixFromDeploymentSchedule(schedule *storepb.Schedule, databas
for _, id := range matchedDatabaseList {
databaseList = append(databaseList, databaseMap[id])
}
- // sort databases in stage based on IDs.
+ // sort databases in stage based on database name.
if len(databaseList) > 0 {
sort.Slice(databaseList, func(i, j int) bool {
- return databaseList[i].UID < databaseList[j].UID
+ return databaseList[i].String() < databaseList[j].String()
})
}
diff --git a/backend/utils/utils_test.go b/backend/utils/utils_test.go
index 2c74074420..e6406d841b 100644
--- a/backend/utils/utils_test.go
+++ b/backend/utils/utils_test.go
@@ -14,7 +14,7 @@ import (
func TestGetDatabaseMatrixFromDeploymentSchedule(t *testing.T) {
dbs := []*store.DatabaseMessage{
{
- UID: 0,
+ InstanceID: "instance1",
DatabaseName: "hello",
Metadata: &storepb.DatabaseMetadata{
Labels: map[string]string{
@@ -25,7 +25,7 @@ func TestGetDatabaseMatrixFromDeploymentSchedule(t *testing.T) {
},
},
{
- UID: 1,
+ InstanceID: "instance2",
DatabaseName: "hello",
Metadata: &storepb.DatabaseMetadata{
Labels: map[string]string{
@@ -36,7 +36,7 @@ func TestGetDatabaseMatrixFromDeploymentSchedule(t *testing.T) {
},
},
{
- UID: 2,
+ InstanceID: "instance3",
DatabaseName: "hello",
Metadata: &storepb.DatabaseMetadata{
Labels: map[string]string{
@@ -47,7 +47,7 @@ func TestGetDatabaseMatrixFromDeploymentSchedule(t *testing.T) {
},
},
{
- UID: 3,
+ InstanceID: "instance4",
DatabaseName: "hello",
Metadata: &storepb.DatabaseMetadata{
Labels: map[string]string{
@@ -57,7 +57,7 @@ func TestGetDatabaseMatrixFromDeploymentSchedule(t *testing.T) {
},
},
{
- UID: 4,
+ InstanceID: "instance5",
DatabaseName: "world",
Metadata: &storepb.DatabaseMetadata{
Labels: map[string]string{
@@ -67,7 +67,7 @@ func TestGetDatabaseMatrixFromDeploymentSchedule(t *testing.T) {
},
},
{
- UID: 5,
+ InstanceID: "instance6",
DatabaseName: "db1_us",
Metadata: &storepb.DatabaseMetadata{
Labels: map[string]string{
@@ -77,7 +77,7 @@ func TestGetDatabaseMatrixFromDeploymentSchedule(t *testing.T) {
},
},
{
- UID: 6,
+ InstanceID: "instance7",
DatabaseName: "db1_eu",
Metadata: &storepb.DatabaseMetadata{
Labels: map[string]string{
diff --git a/frontend/src/types/proto/store/plan_check_run.ts b/frontend/src/types/proto/store/plan_check_run.ts
index 2e96ed41dd..5bca37276a 100644
--- a/frontend/src/types/proto/store/plan_check_run.ts
+++ b/frontend/src/types/proto/store/plan_check_run.ts
@@ -23,7 +23,7 @@ export interface PreUpdateBackupDetail {
export interface PlanCheckRunConfig {
sheetUid: number;
changeDatabaseType: PlanCheckRunConfig_ChangeDatabaseType;
- instanceUid: number;
+ instanceId: string;
databaseName: string;
/** @deprecated */
databaseGroupUid?: Long | undefined;
@@ -269,7 +269,7 @@ function createBasePlanCheckRunConfig(): PlanCheckRunConfig {
return {
sheetUid: 0,
changeDatabaseType: PlanCheckRunConfig_ChangeDatabaseType.CHANGE_DATABASE_TYPE_UNSPECIFIED,
- instanceUid: 0,
+ instanceId: "",
databaseName: "",
databaseGroupUid: undefined,
ghostFlags: {},
@@ -285,8 +285,8 @@ export const PlanCheckRunConfig: MessageFns<PlanCheckRunConfig> = {
if (message.changeDatabaseType !== PlanCheckRunConfig_ChangeDatabaseType.CHANGE_DATABASE_TYPE_UNSPECIFIED) {
writer.uint32(16).int32(planCheckRunConfig_ChangeDatabaseTypeToNumber(message.changeDatabaseType));
}
- if (message.instanceUid !== 0) {
- writer.uint32(24).int32(message.instanceUid);
+ if (message.instanceId !== "") {
+ writer.uint32(26).string(message.instanceId);
}
if (message.databaseName !== "") {
writer.uint32(34).string(message.databaseName);
@@ -327,11 +327,11 @@ export const PlanCheckRunConfig: MessageFns<PlanCheckRunConfig> = {
continue;
}
case 3: {
- if (tag !== 24) {
+ if (tag !== 26) {
break;
}
- message.instanceUid = reader.int32();
+ message.instanceId = reader.string();
continue;
}
case 4: {
@@ -384,7 +384,7 @@ export const PlanCheckRunConfig: MessageFns<PlanCheckRunConfig> = {
changeDatabaseType: isSet(object.changeDatabaseType)
? planCheckRunConfig_ChangeDatabaseTypeFromJSON(object.changeDatabaseType)
: PlanCheckRunConfig_ChangeDatabaseType.CHANGE_DATABASE_TYPE_UNSPECIFIED,
- instanceUid: isSet(object.instanceUid) ? globalThis.Number(object.instanceUid) : 0,
+ instanceId: isSet(object.instanceId) ? globalThis.String(object.instanceId) : "",
databaseName: isSet(object.databaseName) ? globalThis.String(object.databaseName) : "",
databaseGroupUid: isSet(object.databaseGroupUid) ? Long.fromValue(object.databaseGroupUid) : undefined,
ghostFlags: isObject(object.ghostFlags)
@@ -407,8 +407,8 @@ export const PlanCheckRunConfig: MessageFns<PlanCheckRunConfig> = {
if (message.changeDatabaseType !== PlanCheckRunConfig_ChangeDatabaseType.CHANGE_DATABASE_TYPE_UNSPECIFIED) {
obj.changeDatabaseType = planCheckRunConfig_ChangeDatabaseTypeToJSON(message.changeDatabaseType);
}
- if (message.instanceUid !== 0) {
- obj.instanceUid = Math.round(message.instanceUid);
+ if (message.instanceId !== "") {
+ obj.instanceId = message.instanceId;
}
if (message.databaseName !== "") {
obj.databaseName = message.databaseName;
@@ -439,7 +439,7 @@ export const PlanCheckRunConfig: MessageFns<PlanCheckRunConfig> = {
message.sheetUid = object.sheetUid ?? 0;
message.changeDatabaseType = object.changeDatabaseType ??
PlanCheckRunConfig_ChangeDatabaseType.CHANGE_DATABASE_TYPE_UNSPECIFIED;
- message.instanceUid = object.instanceUid ?? 0;
+ message.instanceId = object.instanceId ?? "";
message.databaseName = object.databaseName ?? "";
message.databaseGroupUid = (object.databaseGroupUid !== undefined && object.databaseGroupUid !== null)
? Long.fromValue(object.databaseGroupUid)
diff --git a/proto/gen/grpc-doc/store/README.md b/proto/gen/grpc-doc/store/README.md
index 6df556e617..fe006ff9ca 100644
--- a/proto/gen/grpc-doc/store/README.md
+++ b/proto/gen/grpc-doc/store/README.md
@@ -3032,7 +3032,7 @@ InstanceRole is the API message for instance role.
| ----- | ---- | ----- | ----------- |
| sheet_uid | [int32](#int32) | | |
| change_database_type | [PlanCheckRunConfig.ChangeDatabaseType](#bytebase-store-PlanCheckRunConfig-ChangeDatabaseType) | | |
-| instance_uid | [int32](#int32) | | |
+| instance_id | [string](#string) | | |
| database_name | [string](#string) | | |
| database_group_uid | [int64](#int64) | optional | **Deprecated.** |
| ghost_flags | [PlanCheckRunConfig.GhostFlagsEntry](#bytebase-store-PlanCheckRunConfig-GhostFlagsEntry) | repeated | |
diff --git a/proto/gen/grpc-doc/store/index.html b/proto/gen/grpc-doc/store/index.html
index 4e8998d472..9b5c798bb4 100644
--- a/proto/gen/grpc-doc/store/index.html
+++ b/proto/gen/grpc-doc/store/index.html
@@ -8118,8 +8118,8 @@ Format: users/{userUID}. </p></td>
</tr>
<tr>
- <td>instance_uid</td>
- <td><a href="#int32">int32</a></td>
+ <td>instance_id</td>
+ <td><a href="#string">string</a></td>
<td></td>
<td><p> </p></td>
</tr>
diff --git a/proto/generated-go/store/plan_check_run.pb.go b/proto/generated-go/store/plan_check_run.pb.go
index 6031251eab..f06fcbcaad 100644
--- a/proto/generated-go/store/plan_check_run.pb.go
+++ b/proto/generated-go/store/plan_check_run.pb.go
@@ -181,7 +181,7 @@ type PlanCheckRunConfig struct {
state protoimpl.MessageState `protogen:"open.v1"`
SheetUid int32 `protobuf:"varint,1,opt,name=sheet_uid,json=sheetUid,proto3" json:"sheet_uid,omitempty"`
ChangeDatabaseType PlanCheckRunConfig_ChangeDatabaseType `protobuf:"varint,2,opt,name=change_database_type,json=changeDatabaseType,proto3,enum=bytebase.store.PlanCheckRunConfig_ChangeDatabaseType" json:"change_database_type,omitempty"`
- InstanceUid int32 `protobuf:"varint,3,opt,name=instance_uid,json=instanceUid,proto3" json:"instance_uid,omitempty"`
+ InstanceId string `protobuf:"bytes,3,opt,name=instance_id,json=instanceId,proto3" json:"instance_id,omitempty"`
DatabaseName string `protobuf:"bytes,4,opt,name=database_name,json=databaseName,proto3" json:"database_name,omitempty"`
// Deprecated: Marked as deprecated in store/plan_check_run.proto.
DatabaseGroupUid *int64 `protobuf:"varint,5,opt,name=database_group_uid,json=databaseGroupUid,proto3,oneof" json:"database_group_uid,omitempty"`
@@ -236,11 +236,11 @@ func (x *PlanCheckRunConfig) GetChangeDatabaseType() PlanCheckRunConfig_ChangeDa
return PlanCheckRunConfig_CHANGE_DATABASE_TYPE_UNSPECIFIED
}
-func (x *PlanCheckRunConfig) GetInstanceUid() int32 {
+func (x *PlanCheckRunConfig) GetInstanceId() string {
if x != nil {
- return x.InstanceUid
+ return x.InstanceId
}
- return 0
+ return ""
}
func (x *PlanCheckRunConfig) GetDatabaseName() string {
@@ -580,7 +580,7 @@ var file_store_plan_check_run_proto_rawDesc = string([]byte{
0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x33, 0x0a, 0x15, 0x50, 0x72, 0x65, 0x55, 0x70,
0x64, 0x61, 0x74, 0x65, 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c,
0x12, 0x1a, 0x0a, 0x08, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01,
- 0x28, 0x09, 0x52, 0x08, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x22, 0xbc, 0x05, 0x0a,
+ 0x28, 0x09, 0x52, 0x08, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x22, 0xba, 0x05, 0x0a,
0x12, 0x50, 0x6c, 0x61, 0x6e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x75, 0x6e, 0x43, 0x6f, 0x6e,
0x66, 0x69, 0x67, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x68, 0x65, 0x65, 0x74, 0x5f, 0x75, 0x69, 0x64,
0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x73, 0x68, 0x65, 0x65, 0x74, 0x55, 0x69, 0x64,
@@ -590,102 +590,102 @@ var file_store_plan_check_run_proto_rawDesc = string([]byte{
0x50, 0x6c, 0x61, 0x6e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x75, 0x6e, 0x43, 0x6f, 0x6e, 0x66,
0x69, 0x67, 0x2e, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73,
0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x12, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x44, 0x61, 0x74,
- 0x61, 0x62, 0x61, 0x73, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x69, 0x6e, 0x73,
- 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x75, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52,
- 0x0b, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x55, 0x69, 0x64, 0x12, 0x23, 0x0a, 0x0d,
- 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20,
- 0x01, 0x28, 0x09, 0x52, 0x0c, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x4e, 0x61, 0x6d,
- 0x65, 0x12, 0x35, 0x0a, 0x12, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x67, 0x72,
- 0x6f, 0x75, 0x70, 0x5f, 0x75, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x42, 0x02, 0x18,
- 0x01, 0x48, 0x00, 0x52, 0x10, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x47, 0x72, 0x6f,
- 0x75, 0x70, 0x55, 0x69, 0x64, 0x88, 0x01, 0x01, 0x12, 0x53, 0x0a, 0x0b, 0x67, 0x68, 0x6f, 0x73,
- 0x74, 0x5f, 0x66, 0x6c, 0x61, 0x67, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x32, 0x2e,
- 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x50,
- 0x6c, 0x61, 0x6e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x75, 0x6e, 0x43, 0x6f, 0x6e, 0x66, 0x69,
- 0x67, 0x2e, 0x47, 0x68, 0x6f, 0x73, 0x74, 0x46, 0x6c, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72,
- 0x79, 0x52, 0x0a, 0x67, 0x68, 0x6f, 0x73, 0x74, 0x46, 0x6c, 0x61, 0x67, 0x73, 0x12, 0x63, 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, 0x07, 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, 0x48, 0x01, 0x52, 0x15, 0x70, 0x72, 0x65, 0x55, 0x70, 0x64,
- 0x61, 0x74, 0x65, 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x88,
- 0x01, 0x01, 0x1a, 0x3d, 0x0a, 0x0f, 0x47, 0x68, 0x6f, 0x73, 0x74, 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, 0x74, 0x0a, 0x12, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, 0x62,
- 0x61, 0x73, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x24, 0x0a, 0x20, 0x43, 0x48, 0x41, 0x4e, 0x47,
- 0x45, 0x5f, 0x44, 0x41, 0x54, 0x41, 0x42, 0x41, 0x53, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f,
- 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x07, 0x0a,
- 0x03, 0x44, 0x44, 0x4c, 0x10, 0x01, 0x12, 0x07, 0x0a, 0x03, 0x44, 0x4d, 0x4c, 0x10, 0x02, 0x12,
- 0x07, 0x0a, 0x03, 0x53, 0x44, 0x4c, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x44, 0x44, 0x4c, 0x5f,
- 0x47, 0x48, 0x4f, 0x53, 0x54, 0x10, 0x04, 0x12, 0x0e, 0x0a, 0x0a, 0x53, 0x51, 0x4c, 0x5f, 0x45,
- 0x44, 0x49, 0x54, 0x4f, 0x52, 0x10, 0x05, 0x42, 0x15, 0x0a, 0x13, 0x5f, 0x64, 0x61, 0x74, 0x61,
- 0x62, 0x61, 0x73, 0x65, 0x5f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x75, 0x69, 0x64, 0x42, 0x1b,
- 0x0a, 0x19, 0x5f, 0x70, 0x72, 0x65, 0x5f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x62, 0x61,
- 0x63, 0x6b, 0x75, 0x70, 0x5f, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x22, 0xb0, 0x07, 0x0a, 0x12,
- 0x50, 0x6c, 0x61, 0x6e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x75, 0x6e, 0x52, 0x65, 0x73, 0x75,
- 0x6c, 0x74, 0x12, 0x43, 0x0a, 0x07, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x18, 0x01, 0x20,
- 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73,
- 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x50, 0x6c, 0x61, 0x6e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x75,
- 0x6e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x2e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x07,
- 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72,
- 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x1a, 0xbe, 0x06,
- 0x0a, 0x06, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x48, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74,
- 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x30, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62,
- 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x50, 0x6c, 0x61, 0x6e, 0x43, 0x68,
- 0x65, 0x63, 0x6b, 0x52, 0x75, 0x6e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x2e, 0x52, 0x65, 0x73,
- 0x75, 0x6c, 0x74, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74,
- 0x75, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
- 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74,
- 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65,
- 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05,
- 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x6a, 0x0a, 0x12, 0x73, 0x71, 0x6c, 0x5f, 0x73, 0x75,
- 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x5f, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x05, 0x20, 0x01,
- 0x28, 0x0b, 0x32, 0x3a, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74,
- 0x6f, 0x72, 0x65, 0x2e, 0x50, 0x6c, 0x61, 0x6e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x75, 0x6e,
- 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x2e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x2e, 0x53, 0x71,
- 0x6c, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x48, 0x00,
- 0x52, 0x10, 0x73, 0x71, 0x6c, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x70, 0x6f,
- 0x72, 0x74, 0x12, 0x67, 0x0a, 0x11, 0x73, 0x71, 0x6c, 0x5f, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77,
- 0x5f, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x39, 0x2e,
+ 0x61, 0x62, 0x61, 0x73, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x6e, 0x73,
+ 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a,
+ 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x64, 0x61,
+ 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28,
+ 0x09, 0x52, 0x0c, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12,
+ 0x35, 0x0a, 0x12, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x67, 0x72, 0x6f, 0x75,
+ 0x70, 0x5f, 0x75, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x42, 0x02, 0x18, 0x01, 0x48,
+ 0x00, 0x52, 0x10, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70,
+ 0x55, 0x69, 0x64, 0x88, 0x01, 0x01, 0x12, 0x53, 0x0a, 0x0b, 0x67, 0x68, 0x6f, 0x73, 0x74, 0x5f,
+ 0x66, 0x6c, 0x61, 0x67, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x62, 0x79,
+ 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x50, 0x6c, 0x61,
+ 0x6e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x75, 0x6e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e,
+ 0x47, 0x68, 0x6f, 0x73, 0x74, 0x46, 0x6c, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52,
+ 0x0a, 0x67, 0x68, 0x6f, 0x73, 0x74, 0x46, 0x6c, 0x61, 0x67, 0x73, 0x12, 0x63, 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, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e,
0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x50,
- 0x6c, 0x61, 0x6e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x75, 0x6e, 0x52, 0x65, 0x73, 0x75, 0x6c,
- 0x74, 0x2e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x2e, 0x53, 0x71, 0x6c, 0x52, 0x65, 0x76, 0x69,
- 0x65, 0x77, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x48, 0x00, 0x52, 0x0f, 0x73, 0x71, 0x6c, 0x52,
- 0x65, 0x76, 0x69, 0x65, 0x77, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x1a, 0xb5, 0x01, 0x0a, 0x10,
- 0x53, 0x71, 0x6c, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74,
- 0x12, 0x27, 0x0a, 0x0f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x79,
- 0x70, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0e, 0x73, 0x74, 0x61, 0x74, 0x65,
- 0x6d, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x73, 0x12, 0x23, 0x0a, 0x0d, 0x61, 0x66, 0x66,
- 0x65, 0x63, 0x74, 0x65, 0x64, 0x5f, 0x72, 0x6f, 0x77, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05,
- 0x52, 0x0c, 0x61, 0x66, 0x66, 0x65, 0x63, 0x74, 0x65, 0x64, 0x52, 0x6f, 0x77, 0x73, 0x12, 0x4d,
- 0x0a, 0x11, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x64, 0x5f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72,
- 0x63, 0x65, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x62, 0x79, 0x74, 0x65,
- 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x43, 0x68, 0x61, 0x6e, 0x67,
- 0x65, 0x64, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x10, 0x63, 0x68, 0x61,
- 0x6e, 0x67, 0x65, 0x64, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x4a, 0x04, 0x08,
- 0x01, 0x10, 0x02, 0x1a, 0xc7, 0x01, 0x0a, 0x0f, 0x53, 0x71, 0x6c, 0x52, 0x65, 0x76, 0x69, 0x65,
- 0x77, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x69, 0x6e, 0x65, 0x18,
- 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x63,
- 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x63, 0x6f, 0x6c,
- 0x75, 0x6d, 0x6e, 0x12, 0x3f, 0x0a, 0x0e, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x70, 0x6f, 0x73,
- 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x62, 0x79,
- 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x50, 0x6f, 0x73,
- 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0d, 0x73, 0x74, 0x61, 0x72, 0x74, 0x50, 0x6f, 0x73, 0x69,
- 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3b, 0x0a, 0x0c, 0x65, 0x6e, 0x64, 0x5f, 0x70, 0x6f, 0x73, 0x69,
- 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x62, 0x79, 0x74,
- 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x50, 0x6f, 0x73, 0x69,
- 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x65, 0x6e, 0x64, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f,
- 0x6e, 0x4a, 0x04, 0x08, 0x03, 0x10, 0x04, 0x4a, 0x04, 0x08, 0x04, 0x10, 0x05, 0x22, 0x45, 0x0a,
- 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x12, 0x53, 0x54, 0x41, 0x54, 0x55,
- 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12,
- 0x09, 0x0a, 0x05, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x57, 0x41,
- 0x52, 0x4e, 0x49, 0x4e, 0x47, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x55, 0x43, 0x43, 0x45,
- 0x53, 0x53, 0x10, 0x03, 0x42, 0x08, 0x0a, 0x06, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 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,
+ 0x72, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x44, 0x65,
+ 0x74, 0x61, 0x69, 0x6c, 0x48, 0x01, 0x52, 0x15, 0x70, 0x72, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74,
+ 0x65, 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x88, 0x01, 0x01,
+ 0x1a, 0x3d, 0x0a, 0x0f, 0x47, 0x68, 0x6f, 0x73, 0x74, 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,
+ 0x74, 0x0a, 0x12, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73,
+ 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x24, 0x0a, 0x20, 0x43, 0x48, 0x41, 0x4e, 0x47, 0x45, 0x5f,
+ 0x44, 0x41, 0x54, 0x41, 0x42, 0x41, 0x53, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e,
+ 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x44,
+ 0x44, 0x4c, 0x10, 0x01, 0x12, 0x07, 0x0a, 0x03, 0x44, 0x4d, 0x4c, 0x10, 0x02, 0x12, 0x07, 0x0a,
+ 0x03, 0x53, 0x44, 0x4c, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x44, 0x44, 0x4c, 0x5f, 0x47, 0x48,
+ 0x4f, 0x53, 0x54, 0x10, 0x04, 0x12, 0x0e, 0x0a, 0x0a, 0x53, 0x51, 0x4c, 0x5f, 0x45, 0x44, 0x49,
+ 0x54, 0x4f, 0x52, 0x10, 0x05, 0x42, 0x15, 0x0a, 0x13, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61,
+ 0x73, 0x65, 0x5f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x75, 0x69, 0x64, 0x42, 0x1b, 0x0a, 0x19,
+ 0x5f, 0x70, 0x72, 0x65, 0x5f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x62, 0x61, 0x63, 0x6b,
+ 0x75, 0x70, 0x5f, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x22, 0xb0, 0x07, 0x0a, 0x12, 0x50, 0x6c,
+ 0x61, 0x6e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x75, 0x6e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74,
+ 0x12, 0x43, 0x0a, 0x07, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28,
+ 0x0b, 0x32, 0x29, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f,
+ 0x72, 0x65, 0x2e, 0x50, 0x6c, 0x61, 0x6e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x75, 0x6e, 0x52,
+ 0x65, 0x73, 0x75, 0x6c, 0x74, 0x2e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x07, 0x72, 0x65,
+ 0x73, 0x75, 0x6c, 0x74, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02,
+ 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x1a, 0xbe, 0x06, 0x0a, 0x06,
+ 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x48, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73,
+ 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x30, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73,
+ 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x50, 0x6c, 0x61, 0x6e, 0x43, 0x68, 0x65, 0x63,
+ 0x6b, 0x52, 0x75, 0x6e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x2e, 0x52, 0x65, 0x73, 0x75, 0x6c,
+ 0x74, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73,
+ 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
+ 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e,
+ 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74,
+ 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04,
+ 0x63, 0x6f, 0x64, 0x65, 0x12, 0x6a, 0x0a, 0x12, 0x73, 0x71, 0x6c, 0x5f, 0x73, 0x75, 0x6d, 0x6d,
+ 0x61, 0x72, 0x79, 0x5f, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b,
+ 0x32, 0x3a, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72,
+ 0x65, 0x2e, 0x50, 0x6c, 0x61, 0x6e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x75, 0x6e, 0x52, 0x65,
+ 0x73, 0x75, 0x6c, 0x74, 0x2e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x2e, 0x53, 0x71, 0x6c, 0x53,
+ 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x48, 0x00, 0x52, 0x10,
+ 0x73, 0x71, 0x6c, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74,
+ 0x12, 0x67, 0x0a, 0x11, 0x73, 0x71, 0x6c, 0x5f, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x5f, 0x72,
+ 0x65, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x39, 0x2e, 0x62, 0x79,
+ 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x50, 0x6c, 0x61,
+ 0x6e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x75, 0x6e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x2e,
+ 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x2e, 0x53, 0x71, 0x6c, 0x52, 0x65, 0x76, 0x69, 0x65, 0x77,
+ 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x48, 0x00, 0x52, 0x0f, 0x73, 0x71, 0x6c, 0x52, 0x65, 0x76,
+ 0x69, 0x65, 0x77, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x1a, 0xb5, 0x01, 0x0a, 0x10, 0x53, 0x71,
+ 0x6c, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x27,
+ 0x0a, 0x0f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65,
+ 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x6d, 0x65,
+ 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x73, 0x12, 0x23, 0x0a, 0x0d, 0x61, 0x66, 0x66, 0x65, 0x63,
+ 0x74, 0x65, 0x64, 0x5f, 0x72, 0x6f, 0x77, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c,
+ 0x61, 0x66, 0x66, 0x65, 0x63, 0x74, 0x65, 0x64, 0x52, 0x6f, 0x77, 0x73, 0x12, 0x4d, 0x0a, 0x11,
+ 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x64, 0x5f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65,
+ 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61,
+ 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x64,
+ 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x10, 0x63, 0x68, 0x61, 0x6e, 0x67,
+ 0x65, 0x64, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x4a, 0x04, 0x08, 0x01, 0x10,
+ 0x02, 0x1a, 0xc7, 0x01, 0x0a, 0x0f, 0x53, 0x71, 0x6c, 0x52, 0x65, 0x76, 0x69, 0x65, 0x77, 0x52,
+ 0x65, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x69, 0x6e, 0x65, 0x18, 0x01, 0x20,
+ 0x01, 0x28, 0x05, 0x52, 0x04, 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6c,
+ 0x75, 0x6d, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d,
+ 0x6e, 0x12, 0x3f, 0x0a, 0x0e, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74,
+ 0x69, 0x6f, 0x6e, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x62, 0x79, 0x74, 0x65,
+ 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x50, 0x6f, 0x73, 0x69, 0x74,
+ 0x69, 0x6f, 0x6e, 0x52, 0x0d, 0x73, 0x74, 0x61, 0x72, 0x74, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69,
+ 0x6f, 0x6e, 0x12, 0x3b, 0x0a, 0x0c, 0x65, 0x6e, 0x64, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69,
+ 0x6f, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62,
+ 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69,
+ 0x6f, 0x6e, 0x52, 0x0b, 0x65, 0x6e, 0x64, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x4a,
+ 0x04, 0x08, 0x03, 0x10, 0x04, 0x4a, 0x04, 0x08, 0x04, 0x10, 0x05, 0x22, 0x45, 0x0a, 0x06, 0x53,
+ 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x12, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f,
+ 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x09, 0x0a,
+ 0x05, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x57, 0x41, 0x52, 0x4e,
+ 0x49, 0x4e, 0x47, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x55, 0x43, 0x43, 0x45, 0x53, 0x53,
+ 0x10, 0x03, 0x42, 0x08, 0x0a, 0x06, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 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 (
diff --git a/proto/store/plan_check_run.proto b/proto/store/plan_check_run.proto
index 422c02cfc2..11cc5bce27 100644
--- a/proto/store/plan_check_run.proto
+++ b/proto/store/plan_check_run.proto
@@ -16,7 +16,7 @@ message PreUpdateBackupDetail {
message PlanCheckRunConfig {
int32 sheet_uid = 1;
ChangeDatabaseType change_database_type = 2;
- int32 instance_uid = 3;
+ string instance_id = 3;
string database_name = 4;
optional int64 database_group_uid = 5 [deprecated = true];