Skip to content

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

Remove unused PatchIndex

天舟41acac8d5ae3
diff --git a/api/table_index.go b/api/table_index.go
index e81b06519b..9a7f8c9052 100644
--- a/api/table_index.go
+++ b/api/table_index.go
@@ -67,17 +67,8 @@ func (find *IndexFind) String() string {
return string(str)
}
-type IndexPatch struct {
- ID int
-
- // Standard fields
- // Value is assigned from the jwt subject field passed by the client.
- UpdaterId int
-}
-
type IndexService interface {
CreateIndex(ctx context.Context, create *IndexCreate) (*Index, error)
FindIndexList(ctx context.Context, find *IndexFind) ([]*Index, error)
FindIndex(ctx context.Context, find *IndexFind) (*Index, error)
- PatchIndex(ctx context.Context, patch *IndexPatch) (*Index, error)
}
diff --git a/store/table_index.go b/store/table_index.go
index 8ae52470d8..6ba4c2e0b6 100644
--- a/store/table_index.go
+++ b/store/table_index.go
@@ -82,27 +82,6 @@ func (s *IndexService) FindIndex(ctx context.Context, find *api.IndexFind) (*api
return list[0], nil
}
-// PatchIndex updates an existing index by ID.
-// Returns ENOTFOUND if index does not exist.
-func (s *IndexService) PatchIndex(ctx context.Context, patch *api.IndexPatch) (*api.Index, error) {
- tx, err := s.db.BeginTx(ctx, nil)
- if err != nil {
- return nil, FormatError(err)
- }
- defer tx.Rollback()
-
- index, err := s.patchIndex(ctx, tx, patch)
- if err != nil {
- return nil, FormatError(err)
- }
-
- if err := tx.Commit(); err != nil {
- return nil, FormatError(err)
- }
-
- return index, nil
-}
-
// createIndex creates a new index.
func (s *IndexService) createIndex(ctx context.Context, tx *Tx, create *api.IndexCreate) (*api.Index, error) {
// Insert row into index.
@@ -241,51 +220,3 @@ func (s *IndexService) findIndexList(ctx context.Context, tx *Tx, find *api.Inde
return list, nil
}
-
-// patchIndex updates a index by ID. Returns the new state of the index after update.
-func (s *IndexService) patchIndex(ctx context.Context, tx *Tx, patch *api.IndexPatch) (*api.Index, error) {
- // Build UPDATE clause.
- set, args := []string{"updater_id = ?"}, []interface{}{patch.UpdaterId}
-
- args = append(args, patch.ID)
-
- // Execute update query with RETURNING.
- row, err := tx.QueryContext(ctx, `
- UPDATE idx
- SET `+strings.Join(set, ", ")+`
- WHERE id = ?`+
- "RETURNING id, creator_id, created_ts, updater_id, updated_ts, database_id, table_id, name, expression, position, `type`, `unique`, visible, comment"+`
- `,
- args...,
- )
- if err != nil {
- return nil, FormatError(err)
- }
- defer row.Close()
-
- if row.Next() {
- var index api.Index
- if err := row.Scan(
- &index.ID,
- &index.CreatorId,
- &index.CreatedTs,
- &index.UpdaterId,
- &index.UpdatedTs,
- &index.DatabaseId,
- &index.TableId,
- &index.Name,
- &index.Expression,
- &index.Position,
- &index.Type,
- &index.Unique,
- &index.Visible,
- &index.Comment,
- ); err != nil {
- return nil, FormatError(err)
- }
-
- return &index, nil
- }
-
- return nil, &common.Error{Code: common.NotFound, Err: fmt.Errorf("index ID not found: %d", patch.ID)}
-}