Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: remove unneeded fields (#1223)
Yilong Lia80ad861c7a4
diff --git a/api/backup.go b/api/backup.goindex e8d2980028..98303ce447 100644--- a/api/backup.go+++ b/api/backup.go@@ -169,7 +169,7 @@ type BackupSetting struct {DatabaseID int `jsonapi:"attr,databaseId"`// Do not return this to the client since the client always has the database context and fetching the// database object and all its own related objects is a bit expensive.- // TODO(dragonly): Maybe implementing a good hierarchical caching mechanism can resolve this issue? Needs benchmarks.+ // TODO(dragonly): do we need this field?Database *Database// Domain specific fieldsdiff --git a/api/table.go b/api/table.goindex 9b35f49d59..3cf8bfaded 100644--- a/api/table.go+++ b/api/table.go@@ -17,7 +17,6 @@ type Table struct {UpdatedTs int64 `jsonapi:"attr,updatedTs"`// Related fields- // TODO(dragonly): seems like not using this field?DatabaseID intDatabase *Database `jsonapi:"relation,database"`diff --git a/api/view.go b/api/view.goindex 2155e186ac..e0ef51ca8d 100644--- a/api/view.go+++ b/api/view.go@@ -17,7 +17,6 @@ type View struct {UpdatedTs int64 `jsonapi:"attr,updatedTs"`// Related fields- // TODO(dragonly): seems like not using this field?DatabaseID intDatabase *Database `jsonapi:"relation,database"`diff --git a/server/backup_runner.go b/server/backup_runner.goindex cce31a96c2..82eedcb225 100644--- a/server/backup_runner.go+++ b/server/backup_runner.go@@ -89,7 +89,6 @@ func (s *BackupRunner) Run(ctx context.Context, wg *sync.WaitGroup) {zap.Error(err))continue}- // TODO(dragonly): what's the purpose of this assignment?backupSetting.Database = dbbackupName := fmt.Sprintf("%s-%s-%s-autobackup", api.ProjectShortSlug(db.Project), api.EnvSlug(db.Instance.Environment), t.Format("20060102T030405"))diff --git a/server/database.go b/server/database.goindex b369038645..332a0b447c 100644--- a/server/database.go+++ b/server/database.go@@ -343,14 +343,6 @@ func (s *Server) registerDatabaseRoutes(g *echo.Group) {return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("ID is not a number: %s", c.Param("id"))).SetInternal(err)}- database, err := s.store.GetDatabase(ctx, &api.DatabaseFind{ID: &id})- if err != nil {- return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch database ID: %v", id)).SetInternal(err)- }- if database == nil {- return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Database not found with ID %d", id))- }-tableFind := &api.TableFind{DatabaseID: &id,}@@ -360,7 +352,6 @@ func (s *Server) registerDatabaseRoutes(g *echo.Group) {}for _, table := range tableList {- table.Database = databasecolumnFind := &api.ColumnFind{DatabaseID: &id,TableID: &table.ID,@@ -452,14 +443,6 @@ func (s *Server) registerDatabaseRoutes(g *echo.Group) {return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("ID is not a number: %s", c.Param("id"))).SetInternal(err)}- database, err := s.store.GetDatabase(ctx, &api.DatabaseFind{ID: &id})- if err != nil {- return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch database ID: %v", id)).SetInternal(err)- }- if database == nil {- return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Database not found with ID %d", id))- }-viewFind := &api.ViewFind{DatabaseID: &id,}@@ -467,10 +450,6 @@ func (s *Server) registerDatabaseRoutes(g *echo.Group) {if err != nil {return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch view list for database ID: %d", id)).SetInternal(err)}- // TODO(dragonly): should we do this in composeView()?- for _, view := range viewList {- view.Database = database- }c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)if err := jsonapi.MarshalPayload(c.Response().Writer, viewList); err != nil {@@ -808,7 +787,6 @@ func (s *Server) registerDatabaseRoutes(g *echo.Group) {func (s *Server) setDatabaseLabels(ctx context.Context, labelsJSON string, database *api.Database, project *api.Project, updaterID int, validateOnly bool) error {// NOTE: this is a partially filled DatabaseLabel- // TODO(dragonly): should we make it cleaner?var labels []*api.DatabaseLabelif err := json.Unmarshal([]byte(labelsJSON), &labels); err != nil {return errdiff --git a/server/pipeline.go b/server/pipeline.goindex 9f2d966827..c3a9ae9cf2 100644--- a/server/pipeline.go+++ b/server/pipeline.go@@ -6,7 +6,6 @@ import ("github.com/bytebase/bytebase/api")-// TODO(dragonly): remove this hack.func (s *Server) composePipelineRelationshipValidateOnly(ctx context.Context, pipeline *api.Pipeline) error {var err errordiff --git a/server/project.go b/server/project.goindex b7ac9b74fc..3dc5d3d8d5 100644--- a/server/project.go+++ b/server/project.go@@ -96,7 +96,6 @@ func (s *Server) registerProjectRoutes(g *echo.Group) {for _, project := range projectList {projectList = append(projectList, project)// We will filter those project with the current principle as an inactive member (the role provider differs from that of the project)- // TODO(dragonly): move this if-branch out of the for loop to optimize access patternif projectFind.PrincipalID != nil {principalID := *projectFind.PrincipalIDroleProvider := project.RoleProviderdiff --git a/server/stage.go b/server/stage.goindex e18d030ee4..da25bd3e2c 100644--- a/server/stage.go+++ b/server/stage.go@@ -6,7 +6,6 @@ import ("github.com/bytebase/bytebase/api")-// TODO(dragonly): remove this hackfunc (s *Server) composeStageRelationshipValidateOnly(ctx context.Context, stage *api.Stage) error {var err errorstage.Creator, err = s.store.GetPrincipalByID(ctx, stage.CreatorID)diff --git a/server/task.go b/server/task.goindex a38cf56895..dc50ae1740 100644--- a/server/task.go+++ b/server/task.go@@ -374,7 +374,6 @@ func (s *Server) registerTaskRoutes(g *echo.Group) {})}-// TODO(dragonly): remove this hackfunc (s *Server) composeTaskRelationshipValidateOnly(ctx context.Context, task *api.Task) error {var err errordiff --git a/store/table.go b/store/table.goindex a641a4fffc..0a20cb3d20 100644--- a/store/table.go+++ b/store/table.go@@ -150,6 +150,12 @@ func (s *Store) composeTable(ctx context.Context, raw *tableRaw) (*api.Table, er}table.Updater = updater+ database, err := s.GetDatabase(ctx, &api.DatabaseFind{ID: &table.DatabaseID})+ if err != nil {+ return nil, err+ }+ table.Database = database+return table, nil}diff --git a/store/view.go b/store/view.goindex e1646bb204..84dabad6f9 100644--- a/store/view.go+++ b/store/view.go@@ -118,6 +118,13 @@ func (s *Store) composeView(ctx context.Context, raw *viewRaw) (*api.View, errorreturn nil, err}view.Updater = updater++ database, err := s.GetDatabase(ctx, &api.DatabaseFind{ID: &view.DatabaseID})+ if err != nil {+ return nil, err+ }+ view.Database = database+return view, nil}diff --git a/tests/backup_restore_test.go b/tests/backup_restore_test.goindex cd858414c0..8020a5ed50 100644--- a/tests/backup_restore_test.go+++ b/tests/backup_restore_test.go@@ -21,7 +21,8 @@ import (// TestBackupRestoreBasic tests basic backup and restore behavior// The test plan is:-// 1. create schema with index and constraint and populate data (TODO(dragonly): add routine/event/trigger)+// TODO(dragonly): add routine/event/trigger+// 1. create schema with index and constraint and populate data// 2. create a full backup// 3. clear data// 4. restore data