fix: seed now merges attributes instead of overwriting on upsert, add enrollment attrs to seed
Some checks failed
ci / build-test (push) Has been cancelled
ci / docker-build (push) Has been cancelled

This commit is contained in:
2026-07-08 12:02:46 +02:00
parent f07668c1c3
commit 4724d6f297
2 changed files with 8 additions and 3 deletions

View File

@@ -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)