feat(org): add organization and membership contract and storage
This commit is contained in:
1 parent
a0551a34b8
commit
bdc5855001
90 files changed
+17545
-480
No files matched your search
@@ -140,6 +140,40 @@ type MailRequest struct {
|
||||
CreatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type Membership struct {
|
||||
ID pgtype.UUID
|
||||
OrganizationID pgtype.UUID
|
||||
UserID pgtype.UUID
|
||||
Role string
|
||||
State string
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type Organization struct {
|
||||
ID pgtype.UUID
|
||||
Name string
|
||||
Description pgtype.Text
|
||||
Sphere pgtype.Text
|
||||
ContactWebsite pgtype.Text
|
||||
ContactEmail pgtype.Text
|
||||
ContactPhone pgtype.Text
|
||||
ContactTelegram pgtype.Text
|
||||
VerificationLevel string
|
||||
VerificationBasis string
|
||||
VerificationChangedAt pgtype.Timestamptz
|
||||
Version int64
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type OrganizationRepresentative struct {
|
||||
OrganizationID pgtype.UUID
|
||||
Ordinal int16
|
||||
Name string
|
||||
JobTitle string
|
||||
}
|
||||
|
||||
type OutboxEvent struct {
|
||||
Position pgtype.Int8
|
||||
EventID pgtype.UUID
|
||||
|
||||
@@ -0,0 +1,505 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: organizations.sql
|
||||
|
||||
package sqlc
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
const deleteOrganizationRepresentatives = `-- name: DeleteOrganizationRepresentatives :exec
|
||||
DELETE FROM organization_representatives
|
||||
WHERE organization_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteOrganizationRepresentatives(ctx context.Context, organizationID pgtype.UUID) error {
|
||||
_, err := q.db.Exec(ctx, deleteOrganizationRepresentatives, organizationID)
|
||||
return err
|
||||
}
|
||||
|
||||
const getMembership = `-- name: GetMembership :one
|
||||
SELECT
|
||||
id,
|
||||
organization_id,
|
||||
user_id,
|
||||
role,
|
||||
state,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM memberships
|
||||
WHERE
|
||||
organization_id = $1
|
||||
AND user_id = $2
|
||||
`
|
||||
|
||||
type GetMembershipParams struct {
|
||||
OrganizationID pgtype.UUID
|
||||
UserID pgtype.UUID
|
||||
}
|
||||
|
||||
// Reads the membership of one account in one organization, in any state.
|
||||
func (q *Queries) GetMembership(ctx context.Context, arg GetMembershipParams) (Membership, error) {
|
||||
row := q.db.QueryRow(ctx, getMembership, arg.OrganizationID, arg.UserID)
|
||||
var i Membership
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.OrganizationID,
|
||||
&i.UserID,
|
||||
&i.Role,
|
||||
&i.State,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getOrganizationForMember = `-- name: GetOrganizationForMember :one
|
||||
SELECT
|
||||
organization.id,
|
||||
organization.name,
|
||||
organization.description,
|
||||
organization.sphere,
|
||||
organization.contact_website,
|
||||
organization.contact_email,
|
||||
organization.contact_phone,
|
||||
organization.contact_telegram,
|
||||
organization.verification_level,
|
||||
organization.verification_basis,
|
||||
organization.verification_changed_at,
|
||||
organization.version,
|
||||
organization.created_at,
|
||||
organization.updated_at,
|
||||
coalesce((
|
||||
SELECT
|
||||
jsonb_agg(
|
||||
jsonb_build_object('name', representative.name, 'job_title', representative.job_title)
|
||||
ORDER BY representative.ordinal
|
||||
)
|
||||
FROM organization_representatives AS representative
|
||||
WHERE representative.organization_id = organization.id
|
||||
), '[]'::jsonb)::text AS representatives,
|
||||
membership.id AS membership_id,
|
||||
membership.role AS membership_role,
|
||||
membership.state AS membership_state,
|
||||
membership.created_at AS membership_created_at,
|
||||
membership.updated_at AS membership_updated_at
|
||||
FROM organizations AS organization
|
||||
INNER JOIN memberships AS membership ON organization.id = membership.organization_id
|
||||
WHERE
|
||||
organization.id = $1
|
||||
AND membership.user_id = $2
|
||||
AND membership.state = 'active'
|
||||
`
|
||||
|
||||
type GetOrganizationForMemberParams struct {
|
||||
OrganizationID pgtype.UUID
|
||||
UserID pgtype.UUID
|
||||
}
|
||||
|
||||
type GetOrganizationForMemberRow struct {
|
||||
ID pgtype.UUID
|
||||
Name string
|
||||
Description pgtype.Text
|
||||
Sphere pgtype.Text
|
||||
ContactWebsite pgtype.Text
|
||||
ContactEmail pgtype.Text
|
||||
ContactPhone pgtype.Text
|
||||
ContactTelegram pgtype.Text
|
||||
VerificationLevel string
|
||||
VerificationBasis string
|
||||
VerificationChangedAt pgtype.Timestamptz
|
||||
Version int64
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
Representatives string
|
||||
MembershipID pgtype.UUID
|
||||
MembershipRole string
|
||||
MembershipState string
|
||||
MembershipCreatedAt pgtype.Timestamptz
|
||||
MembershipUpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
// Reads an organization together with the membership of one account in it
|
||||
// and its representatives in list order, as one statement, so the profile and
|
||||
// the list come from one snapshot. Only an active membership matches, so an
|
||||
// unknown organization, an account that is no member, and a suspended,
|
||||
// removed, or left member all return no row and cannot be told apart.
|
||||
func (q *Queries) GetOrganizationForMember(ctx context.Context, arg GetOrganizationForMemberParams) (GetOrganizationForMemberRow, error) {
|
||||
row := q.db.QueryRow(ctx, getOrganizationForMember, arg.OrganizationID, arg.UserID)
|
||||
var i GetOrganizationForMemberRow
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.Name,
|
||||
&i.Description,
|
||||
&i.Sphere,
|
||||
&i.ContactWebsite,
|
||||
&i.ContactEmail,
|
||||
&i.ContactPhone,
|
||||
&i.ContactTelegram,
|
||||
&i.VerificationLevel,
|
||||
&i.VerificationBasis,
|
||||
&i.VerificationChangedAt,
|
||||
&i.Version,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.Representatives,
|
||||
&i.MembershipID,
|
||||
&i.MembershipRole,
|
||||
&i.MembershipState,
|
||||
&i.MembershipCreatedAt,
|
||||
&i.MembershipUpdatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const insertMembership = `-- name: InsertMembership :exec
|
||||
INSERT INTO memberships (
|
||||
id,
|
||||
organization_id,
|
||||
user_id,
|
||||
role,
|
||||
state,
|
||||
created_at,
|
||||
updated_at
|
||||
) VALUES (
|
||||
$1,
|
||||
$2,
|
||||
$3,
|
||||
$4,
|
||||
$5,
|
||||
$6,
|
||||
$7
|
||||
)
|
||||
`
|
||||
|
||||
type InsertMembershipParams struct {
|
||||
ID pgtype.UUID
|
||||
OrganizationID pgtype.UUID
|
||||
UserID pgtype.UUID
|
||||
Role string
|
||||
State string
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
func (q *Queries) InsertMembership(ctx context.Context, arg InsertMembershipParams) error {
|
||||
_, err := q.db.Exec(ctx, insertMembership,
|
||||
arg.ID,
|
||||
arg.OrganizationID,
|
||||
arg.UserID,
|
||||
arg.Role,
|
||||
arg.State,
|
||||
arg.CreatedAt,
|
||||
arg.UpdatedAt,
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
const insertOrganization = `-- name: InsertOrganization :exec
|
||||
INSERT INTO organizations (
|
||||
id,
|
||||
name,
|
||||
description,
|
||||
sphere,
|
||||
contact_website,
|
||||
contact_email,
|
||||
contact_phone,
|
||||
contact_telegram,
|
||||
verification_level,
|
||||
verification_basis,
|
||||
verification_changed_at,
|
||||
version,
|
||||
created_at,
|
||||
updated_at
|
||||
) VALUES (
|
||||
$1,
|
||||
$2,
|
||||
$3,
|
||||
$4,
|
||||
$5,
|
||||
$6,
|
||||
$7,
|
||||
$8,
|
||||
$9,
|
||||
$10,
|
||||
$11,
|
||||
$12,
|
||||
$13,
|
||||
$14
|
||||
)
|
||||
`
|
||||
|
||||
type InsertOrganizationParams struct {
|
||||
ID pgtype.UUID
|
||||
Name string
|
||||
Description pgtype.Text
|
||||
Sphere pgtype.Text
|
||||
ContactWebsite pgtype.Text
|
||||
ContactEmail pgtype.Text
|
||||
ContactPhone pgtype.Text
|
||||
ContactTelegram pgtype.Text
|
||||
VerificationLevel string
|
||||
VerificationBasis string
|
||||
VerificationChangedAt pgtype.Timestamptz
|
||||
Version int64
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
// Stores a new organization with the verification level that the domain
|
||||
// gave it. The deferred constraint organizations_owner_required fails the
|
||||
// transaction at commit unless an active owner membership was inserted in
|
||||
// it too.
|
||||
func (q *Queries) InsertOrganization(ctx context.Context, arg InsertOrganizationParams) error {
|
||||
_, err := q.db.Exec(ctx, insertOrganization,
|
||||
arg.ID,
|
||||
arg.Name,
|
||||
arg.Description,
|
||||
arg.Sphere,
|
||||
arg.ContactWebsite,
|
||||
arg.ContactEmail,
|
||||
arg.ContactPhone,
|
||||
arg.ContactTelegram,
|
||||
arg.VerificationLevel,
|
||||
arg.VerificationBasis,
|
||||
arg.VerificationChangedAt,
|
||||
arg.Version,
|
||||
arg.CreatedAt,
|
||||
arg.UpdatedAt,
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
const insertOrganizationRepresentative = `-- name: InsertOrganizationRepresentative :exec
|
||||
INSERT INTO organization_representatives (
|
||||
organization_id,
|
||||
ordinal,
|
||||
name,
|
||||
job_title
|
||||
) VALUES (
|
||||
$1,
|
||||
$2,
|
||||
$3,
|
||||
$4
|
||||
)
|
||||
`
|
||||
|
||||
type InsertOrganizationRepresentativeParams struct {
|
||||
OrganizationID pgtype.UUID
|
||||
Ordinal int16
|
||||
Name string
|
||||
JobTitle string
|
||||
}
|
||||
|
||||
// Stores one representative at its position in the list. The adapter calls it
|
||||
// once per representative after it deleted the previous list, in the same
|
||||
// transaction.
|
||||
func (q *Queries) InsertOrganizationRepresentative(ctx context.Context, arg InsertOrganizationRepresentativeParams) error {
|
||||
_, err := q.db.Exec(ctx, insertOrganizationRepresentative,
|
||||
arg.OrganizationID,
|
||||
arg.Ordinal,
|
||||
arg.Name,
|
||||
arg.JobTitle,
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
const listOrganizationsForUser = `-- name: ListOrganizationsForUser :many
|
||||
SELECT
|
||||
organization.id,
|
||||
organization.name,
|
||||
organization.verification_level,
|
||||
membership.id AS membership_id,
|
||||
membership.role AS membership_role,
|
||||
membership.state AS membership_state,
|
||||
membership.created_at AS membership_created_at,
|
||||
membership.updated_at AS membership_updated_at
|
||||
FROM memberships AS membership
|
||||
INNER JOIN organizations AS organization ON membership.organization_id = organization.id
|
||||
WHERE
|
||||
membership.user_id = $1
|
||||
AND membership.state = 'active'
|
||||
AND (
|
||||
$2::timestamptz IS NULL
|
||||
OR (membership.created_at, membership.organization_id) < (
|
||||
$2::timestamptz,
|
||||
$3::uuid
|
||||
)
|
||||
)
|
||||
ORDER BY membership.created_at DESC, membership.organization_id DESC
|
||||
LIMIT $4
|
||||
`
|
||||
|
||||
type ListOrganizationsForUserParams struct {
|
||||
UserID pgtype.UUID
|
||||
AfterJoinedAt pgtype.Timestamptz
|
||||
AfterOrganizationID pgtype.UUID
|
||||
RowLimit int32
|
||||
}
|
||||
|
||||
type ListOrganizationsForUserRow struct {
|
||||
ID pgtype.UUID
|
||||
Name string
|
||||
VerificationLevel string
|
||||
MembershipID pgtype.UUID
|
||||
MembershipRole string
|
||||
MembershipState string
|
||||
MembershipCreatedAt pgtype.Timestamptz
|
||||
MembershipUpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
// Lists the organizations where an account has an active membership,
|
||||
// newest membership first. The page continues after the (membership
|
||||
// creation time, organization ID) position of the last item of the
|
||||
// previous page. Only the active memberships of the given account match.
|
||||
func (q *Queries) ListOrganizationsForUser(ctx context.Context, arg ListOrganizationsForUserParams) ([]ListOrganizationsForUserRow, error) {
|
||||
rows, err := q.db.Query(ctx, listOrganizationsForUser,
|
||||
arg.UserID,
|
||||
arg.AfterJoinedAt,
|
||||
arg.AfterOrganizationID,
|
||||
arg.RowLimit,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []ListOrganizationsForUserRow
|
||||
for rows.Next() {
|
||||
var i ListOrganizationsForUserRow
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.Name,
|
||||
&i.VerificationLevel,
|
||||
&i.MembershipID,
|
||||
&i.MembershipRole,
|
||||
&i.MembershipState,
|
||||
&i.MembershipCreatedAt,
|
||||
&i.MembershipUpdatedAt,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const updateOrganizationProfile = `-- name: UpdateOrganizationProfile :one
|
||||
WITH target AS (
|
||||
SELECT id FROM organizations
|
||||
WHERE
|
||||
id = $9
|
||||
AND version = $10
|
||||
FOR UPDATE
|
||||
),
|
||||
|
||||
actor AS (
|
||||
SELECT memberships.id FROM memberships
|
||||
INNER JOIN target ON memberships.organization_id = target.id
|
||||
WHERE
|
||||
memberships.user_id = $11
|
||||
AND memberships.state = 'active'
|
||||
AND memberships.role = any($12::text [])
|
||||
FOR SHARE OF memberships
|
||||
)
|
||||
|
||||
UPDATE organizations
|
||||
SET
|
||||
name = $1,
|
||||
description = $2,
|
||||
sphere = $3,
|
||||
contact_website = $4,
|
||||
contact_email = $5,
|
||||
contact_phone = $6,
|
||||
contact_telegram = $7,
|
||||
updated_at = $8,
|
||||
version = organizations.version + 1
|
||||
FROM actor
|
||||
WHERE
|
||||
organizations.id = $9
|
||||
AND organizations.version = $10
|
||||
RETURNING
|
||||
organizations.id,
|
||||
organizations.name,
|
||||
organizations.description,
|
||||
organizations.sphere,
|
||||
organizations.contact_website,
|
||||
organizations.contact_email,
|
||||
organizations.contact_phone,
|
||||
organizations.contact_telegram,
|
||||
organizations.verification_level,
|
||||
organizations.verification_basis,
|
||||
organizations.verification_changed_at,
|
||||
organizations.version,
|
||||
organizations.created_at,
|
||||
organizations.updated_at
|
||||
`
|
||||
|
||||
type UpdateOrganizationProfileParams struct {
|
||||
Name string
|
||||
Description pgtype.Text
|
||||
Sphere pgtype.Text
|
||||
ContactWebsite pgtype.Text
|
||||
ContactEmail pgtype.Text
|
||||
ContactPhone pgtype.Text
|
||||
ContactTelegram pgtype.Text
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
ID pgtype.UUID
|
||||
ExpectedVersion int64
|
||||
ActorID pgtype.UUID
|
||||
ManagerRoles []string
|
||||
}
|
||||
|
||||
// Changes the profile of an organization over the version the caller read
|
||||
// and advances the version in the same statement. It names no verification
|
||||
// column, so a profile update cannot move the trust level. The change
|
||||
// applies only for an account whose active membership has one of the
|
||||
// manager roles, checked in the statement itself so that a membership that
|
||||
// ended after the caller's read still stops the write. The statement locks
|
||||
// the organization row first and then the actor's membership row FOR SHARE,
|
||||
// so a revocation that commits while the statement waits is seen again
|
||||
// (EvalPlanQual) and stops the write; the order organizations, then
|
||||
// memberships, is the lock order of every writer (member management must
|
||||
// follow it). No row returns for a stale version, an account that is no
|
||||
// active manager, or an unknown organization; the adapter reads the
|
||||
// membership to tell them apart.
|
||||
func (q *Queries) UpdateOrganizationProfile(ctx context.Context, arg UpdateOrganizationProfileParams) (Organization, error) {
|
||||
row := q.db.QueryRow(ctx, updateOrganizationProfile,
|
||||
arg.Name,
|
||||
arg.Description,
|
||||
arg.Sphere,
|
||||
arg.ContactWebsite,
|
||||
arg.ContactEmail,
|
||||
arg.ContactPhone,
|
||||
arg.ContactTelegram,
|
||||
arg.UpdatedAt,
|
||||
arg.ID,
|
||||
arg.ExpectedVersion,
|
||||
arg.ActorID,
|
||||
arg.ManagerRoles,
|
||||
)
|
||||
var i Organization
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.Name,
|
||||
&i.Description,
|
||||
&i.Sphere,
|
||||
&i.ContactWebsite,
|
||||
&i.ContactEmail,
|
||||
&i.ContactPhone,
|
||||
&i.ContactTelegram,
|
||||
&i.VerificationLevel,
|
||||
&i.VerificationBasis,
|
||||
&i.VerificationChangedAt,
|
||||
&i.Version,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
@@ -49,6 +49,7 @@ type Querier interface {
|
||||
// matches no row.
|
||||
ConsumeEmailToken(ctx context.Context, arg ConsumeEmailTokenParams) (EmailToken, error)
|
||||
DeleteMailRequest(ctx context.Context, id pgtype.UUID) (int64, error)
|
||||
DeleteOrganizationRepresentatives(ctx context.Context, organizationID pgtype.UUID) error
|
||||
// Deletes one batch of accounts that stayed unverified since before cutoff,
|
||||
// oldest first, with their tokens, sessions, mail requests, mail deliveries
|
||||
// (and through the deliveries their attempts), and consent records. The
|
||||
@@ -112,6 +113,14 @@ type Querier interface {
|
||||
GetLatestPolicyVersion(ctx context.Context, policyKey string) (PolicyVersion, error)
|
||||
// Reads the usage of the day and the month window without locking.
|
||||
GetMailQuotaUsage(ctx context.Context, arg GetMailQuotaUsageParams) ([]GetMailQuotaUsageRow, error)
|
||||
// Reads the membership of one account in one organization, in any state.
|
||||
GetMembership(ctx context.Context, arg GetMembershipParams) (Membership, error)
|
||||
// Reads an organization together with the membership of one account in it
|
||||
// and its representatives in list order, as one statement, so the profile and
|
||||
// the list come from one snapshot. Only an active membership matches, so an
|
||||
// unknown organization, an account that is no member, and a suspended,
|
||||
// removed, or left member all return no row and cannot be told apart.
|
||||
GetOrganizationForMember(ctx context.Context, arg GetOrganizationForMemberParams) (GetOrganizationForMemberRow, error)
|
||||
// Reads the relay backlog for metrics without locking. Both subqueries use
|
||||
// the partial index on unpublished positions, so the cost follows the backlog
|
||||
// size, not the table size. The age comes from the database clock, the same
|
||||
@@ -153,6 +162,16 @@ type Querier interface {
|
||||
InsertEmailToken(ctx context.Context, arg InsertEmailTokenParams) error
|
||||
InsertMailQuotaReservation(ctx context.Context, arg InsertMailQuotaReservationParams) error
|
||||
InsertMailRequest(ctx context.Context, arg InsertMailRequestParams) error
|
||||
InsertMembership(ctx context.Context, arg InsertMembershipParams) error
|
||||
// Stores a new organization with the verification level that the domain
|
||||
// gave it. The deferred constraint organizations_owner_required fails the
|
||||
// transaction at commit unless an active owner membership was inserted in
|
||||
// it too.
|
||||
InsertOrganization(ctx context.Context, arg InsertOrganizationParams) error
|
||||
// Stores one representative at its position in the list. The adapter calls it
|
||||
// once per representative after it deleted the previous list, in the same
|
||||
// transaction.
|
||||
InsertOrganizationRepresentative(ctx context.Context, arg InsertOrganizationRepresentativeParams) error
|
||||
InsertOutboxEvent(ctx context.Context, arg InsertOutboxEventParams) error
|
||||
// Stores a version and returns the stored row with the publication time and
|
||||
// effective time set by the stamp trigger. A taken ID or version number
|
||||
@@ -189,6 +208,11 @@ type Querier interface {
|
||||
ListConsentRecords(ctx context.Context, arg ListConsentRecordsParams) ([]ListConsentRecordsRow, error)
|
||||
ListCurrentContactConsentRecords(ctx context.Context, arg ListCurrentContactConsentRecordsParams) ([]ListCurrentContactConsentRecordsRow, error)
|
||||
ListDeliveryAttempts(ctx context.Context, deliveryID pgtype.UUID) ([]DeliveryAttempt, error)
|
||||
// Lists the organizations where an account has an active membership,
|
||||
// newest membership first. The page continues after the (membership
|
||||
// creation time, organization ID) position of the last item of the
|
||||
// previous page. Only the active memberships of the given account match.
|
||||
ListOrganizationsForUser(ctx context.Context, arg ListOrganizationsForUserParams) ([]ListOrganizationsForUserRow, error)
|
||||
// Lists the other accounts of a provider that have usage in a month, so
|
||||
// startup can warn about a renamed EMAIL_ACCOUNT.
|
||||
ListOtherMailQuotaAccounts(ctx context.Context, arg ListOtherMailQuotaAccountsParams) ([]string, error)
|
||||
@@ -304,6 +328,20 @@ type Querier interface {
|
||||
// the stored version still equals expected_version and returns 0 rows
|
||||
// otherwise. The trigger refuses a provider change after an attempt.
|
||||
UpdateDeliveryState(ctx context.Context, arg UpdateDeliveryStateParams) (int64, error)
|
||||
// Changes the profile of an organization over the version the caller read
|
||||
// and advances the version in the same statement. It names no verification
|
||||
// column, so a profile update cannot move the trust level. The change
|
||||
// applies only for an account whose active membership has one of the
|
||||
// manager roles, checked in the statement itself so that a membership that
|
||||
// ended after the caller's read still stops the write. The statement locks
|
||||
// the organization row first and then the actor's membership row FOR SHARE,
|
||||
// so a revocation that commits while the statement waits is seen again
|
||||
// (EvalPlanQual) and stops the write; the order organizations, then
|
||||
// memberships, is the lock order of every writer (member management must
|
||||
// follow it). No row returns for a stale version, an account that is no
|
||||
// active manager, or an unknown organization; the adapter reads the
|
||||
// membership to tell them apart.
|
||||
UpdateOrganizationProfile(ctx context.Context, arg UpdateOrganizationProfileParams) (Organization, error)
|
||||
// Replaces the registration of an unverified account and advances the
|
||||
// registration version in the same statement, so no caller can choose it.
|
||||
// The version check rejects a writer that read an older row; a verified
|
||||
|
||||
Reference in new issue
Block a user