fix(secrets): target the scope index in the secrets upsert

A bare ON CONFLICT DO UPDATE fires on any unique constraint violation; naming idx_secrets_scope keeps a future constraint from silently redirecting the update.
This commit is contained in:
Chris Scott committed 2026-10-23 22:59:57 -04:00
1 parent e46cf516c5
commit a0d1d91f18
1 file changed
+1 -1
+1 -1
View File
@@ -52,7 +52,7 @@ export class SecretsService {
.prepare(
`INSERT INTO secrets (kind, repo_id, environment, name, value, created_at, updated_at)
VALUES (?, ?, ?, ?, ?, ?, ?)
ON CONFLICT DO UPDATE SET value = excluded.value, updated_at = excluded.updated_at`,
ON CONFLICT(kind, COALESCE(repo_id, 0), environment, name) DO UPDATE SET value = excluded.value, updated_at = excluded.updated_at`,
)
.run(kind, repoId, normalizedEnvironment, name, storedValue, now, now)
}