feat: use default org for PostUser (#12143)

Instead of assuming only 1 org exists, this uses the
is_default org to place a user in if not specified.
This commit is contained in:
Steven Masley
2024-02-16 08:28:36 -06:00
committed by GitHub
parent 0e1bad4f82
commit 2a8004b1b2
10 changed files with 101 additions and 13 deletions
+25
View File
@@ -3142,6 +3142,31 @@ func (q *sqlQuerier) UpdateMemberRoles(ctx context.Context, arg UpdateMemberRole
return i, err
}
const getDefaultOrganization = `-- name: GetDefaultOrganization :one
SELECT
id, name, description, created_at, updated_at, is_default
FROM
organizations
WHERE
is_default = true
LIMIT
1
`
func (q *sqlQuerier) GetDefaultOrganization(ctx context.Context) (Organization, error) {
row := q.db.QueryRowContext(ctx, getDefaultOrganization)
var i Organization
err := row.Scan(
&i.ID,
&i.Name,
&i.Description,
&i.CreatedAt,
&i.UpdatedAt,
&i.IsDefault,
)
return i, err
}
const getOrganizationByID = `-- name: GetOrganizationByID :one
SELECT
id, name, description, created_at, updated_at, is_default