-- name: UpsertCredential :one
INSERT INTO git_credentials (id, workspace_id, kind, username, encrypted_secret, fingerprint)
VALUES ($1,$2,$3,$4,$5,$6)
ON CONFLICT (workspace_id) DO UPDATE
  SET kind             = EXCLUDED.kind,
      username         = EXCLUDED.username,
      encrypted_secret = EXCLUDED.encrypted_secret,
      fingerprint      = EXCLUDED.fingerprint,
      updated_at       = now()
RETURNING *;

-- name: GetCredentialByWorkspace :one
SELECT * FROM git_credentials WHERE workspace_id = $1;
