Add initial code to support unique per-entry IDs

This code has two caveats for old entries:
1. the ID is being backfiled with a random per-(device,entry) ID. So the ID won't match cross-device.
2. the server-side ID will still be a random ID that is unrelated to the entry ID
This commit is contained in:
David Dworken
2023-09-22 13:16:24 -07:00
parent 2a5a6d65c4
commit a5f11af150
6 changed files with 22 additions and 2 deletions

View File

@@ -18,6 +18,7 @@ import (
"github.com/ddworken/hishtory/client/hctx"
"github.com/ddworken/hishtory/client/lib"
"github.com/ddworken/hishtory/shared"
"github.com/google/uuid"
"github.com/spf13/cobra"
)
@@ -281,6 +282,9 @@ func buildPreArgsHistoryEntry(ctx context.Context) (*data.HistoryEntry, error) {
config := hctx.GetConf(ctx)
entry.DeviceId = config.DeviceId
// entry ID
entry.EntryId = uuid.Must(uuid.NewRandom()).String()
// custom columns
cc, err := buildCustomColumns(ctx)
if err != nil {