From 4724d6f297772296432da58adf5a35e7ff8a17d6 Mon Sep 17 00:00:00 2001 From: dtoro Date: Wed, 8 Jul 2026 12:02:46 +0200 Subject: [PATCH] fix: seed now merges attributes instead of overwriting on upsert, add enrollment attrs to seed --- internal/db/seed.go | 6 ++++-- seeds/inventory.yaml | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/internal/db/seed.go b/internal/db/seed.go index 3b75b48..8c1a352 100644 --- a/internal/db/seed.go +++ b/internal/db/seed.go @@ -123,8 +123,10 @@ func IngestInventorySeed(ctx context.Context, tx pgx.Tx, data map[string]any) (* _, err = tx.Exec(ctx, `INSERT INTO entities (id, slug, type, name, state, attributes, version, created_at, updated_at) VALUES ($1, $2, $3, $4, $5, $6, 1, now(), now()) - ON CONFLICT (slug) DO UPDATE SET type = $3, name = $4, state = $5, - attributes = $6, updated_at = now()`, + ON CONFLICT (slug) DO UPDATE SET + type = EXCLUDED.type, name = EXCLUDED.name, + attributes = entities.attributes || EXCLUDED.attributes, + updated_at = now()`, entityID, slug, typeName, name, nullableStr(state), string(attrsBytes)) if err != nil { return nil, fmt.Errorf("entity %s: %w", slug, err) diff --git a/seeds/inventory.yaml b/seeds/inventory.yaml index 5ebd00a..ee68c81 100644 --- a/seeds/inventory.yaml +++ b/seeds/inventory.yaml @@ -96,7 +96,10 @@ entities: lan_ip: 192.168.178.182 mesh: {netbird: {fqdn: mac-mini-234-17.netbird.selfhosted}} age_pubkey: age169104ee1a9e1577d493820830560197f0adf56bf8f1c369d57c152c03f9437ae - note: only macOS in fleet; future Oikos OS Docker host + note: only macOS in fleet; Oikos Docker host. Enrolled 2026-07-08. + enrolled_at: "2026-07-08T09:49:03Z" + mesh_ip: 192.168.178.182 + hostname: mac-mini - slug: "ws:republic-laptop" type: workstation name: republic-laptop