This commit is contained in:
1 parent
da01f2cbe1
commit
3212437b8d
13 files changed
+633
-110
No files matched your search
@@ -38,6 +38,20 @@ func (q *Queries) EnsureAgentOrgMembership(ctx context.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
const ensureAgentOrgMembershipFor = `-- name: EnsureAgentOrgMembershipFor :exec
|
||||
INSERT INTO memberships (identity_id, org_id, role)
|
||||
SELECT a.identity_id, a.org_id, 'developer' FROM org_agents a
|
||||
WHERE a.identity_id = $1
|
||||
ON CONFLICT (identity_id, org_id, COALESCE(workspace_id, '')) DO NOTHING
|
||||
`
|
||||
|
||||
// Same grant as EnsureAgentOrgMembership for one identity: an agent assigned
|
||||
// to an org after boot (AssignAgent) still gets the developer membership there.
|
||||
func (q *Queries) EnsureAgentOrgMembershipFor(ctx context.Context, identityID string) error {
|
||||
_, err := q.db.Exec(ctx, ensureAgentOrgMembershipFor, identityID)
|
||||
return err
|
||||
}
|
||||
|
||||
const ensureMembership = `-- name: EnsureMembership :exec
|
||||
INSERT INTO memberships (identity_id, org_id, workspace_id, role)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
|
||||
Reference in new issue
Block a user