feat: add assessment, privacy and support flows

This commit is contained in:
TakuyaYagam1 committed 2026-10-08 08:08:25 +03:00
1 parent ee3738ee73
commit e4f24fa202
339 files changed
+56454 -1126

No files matched your search

@@ -405,6 +405,63 @@ func (q *Queries) ListOrganizationsForUser(ctx context.Context, arg ListOrganiza
return items, nil
}
const lockActiveMembership = `-- name: LockActiveMembership :one
WITH locked_organization AS MATERIALIZED (
SELECT organizations.id
FROM organizations
WHERE organizations.id = $2
FOR SHARE
)
SELECT
membership.id AS membership_id,
membership.organization_id,
membership.user_id,
membership.role,
membership.state,
membership.created_at,
membership.updated_at
FROM memberships AS membership
INNER JOIN locked_organization ON locked_organization.id = membership.organization_id
WHERE
membership.user_id = $1
AND membership.state = 'active'
FOR SHARE OF membership
`
type LockActiveMembershipParams struct {
UserID pgtype.UUID
OrganizationID pgtype.UUID
}
type LockActiveMembershipRow struct {
MembershipID pgtype.UUID
OrganizationID pgtype.UUID
UserID pgtype.UUID
Role string
State string
CreatedAt pgtype.Timestamptz
UpdatedAt pgtype.Timestamptz
}
// Locks the organization first and then the active membership, using the
// same order as organization profile writes. A company operation keeps both
// share locks until its transaction commits, so a concurrent revocation
// cannot authorize a write after it has committed.
func (q *Queries) LockActiveMembership(ctx context.Context, arg LockActiveMembershipParams) (LockActiveMembershipRow, error) {
row := q.db.QueryRow(ctx, lockActiveMembership, arg.UserID, arg.OrganizationID)
var i LockActiveMembershipRow
err := row.Scan(
&i.MembershipID,
&i.OrganizationID,
&i.UserID,
&i.Role,
&i.State,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const saveOrganizationCreationResult = `-- name: SaveOrganizationCreationResult :exec
INSERT INTO organization_creation_results (scope_hash, snapshot)
VALUES ($1, $2)