// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.29.0 package organization import ( "context" "database/sql" ) type Querier interface { // Setup-checklist existence probe; reserved types never carry a default. AnyOrgTypeWithDefaultPlan(ctx context.Context) (bool, error) // Operator overview headline. Personal orgs exist one-per-member by // structural convention (design/organization/architecture.md §2), so an // organizations count that includes them tracks the people count and reads // as an error. Negative-space predicate instead of org_type = 'team': // everything active that is neither the auto-created personal type nor a // reserved type counts, so team, enterprise, and deployment-defined types // need no code change here and the reserved system org never appears. CountTeamOrganizations(ctx context.Context) (int64, error) CountWorkspacesByOrgID(ctx context.Context, orgID string) (int64, error) CreateOrgMember(ctx context.Context, arg CreateOrgMemberParams) (OrgMember, error) // Identity is org_id, presentation is name, and organization names are // deliberately not unique. `key` is the optional declarative address // (entity-keys §1 to §4): a caller outside the database -- a seed, a // configuration loader, an API client -- supplies it to name this row // literally. UI-created organizations leave it NULL, and a personal // organization never gets one: a key is never derived from a person's login // or display name (§4). CreateOrganization(ctx context.Context, arg CreateOrganizationParams) (Organization, error) CreateRoleAssignment(ctx context.Context, arg CreateRoleAssignmentParams) (RoleAssignment, error) // The name is what people see and the only thing the create form asks for; // uq_workspaces_org_id_name_ci keeps it unambiguous within the organization // among live workspaces. `key` is the optional declarative address // (entity-keys §3), unique within the organization rather than globally // because a workspace is a child; UI-created workspaces leave it NULL, and a // singleton workspace is addressed through its organization. CreateWorkspace(ctx context.Context, arg CreateWorkspaceParams) (Workspace, error) // Idempotently insert the reserved 'system' org type. is_reserved=TRUE keeps it // out of the operator config UI; default_plan_ladder_id stays NULL, so // auto-provisioning issues no default grant for system orgs. EnsureSystemOrgType(ctx context.Context, arg EnsureSystemOrgTypeParams) error // Idempotently insert the singleton System organization. The partial unique // index uq_organizations_one_system enforces "exactly one System tenant", and // the conflict target repeats the index predicate so Postgres can infer it. // Read back with GetSystemOrganization. // // `system` is one of the two keys the system writes for itself (entity-keys // §4): a fixed constant for a row the console creates by design, not a value // derived from anybody's data. It is written here rather than by the Go // caller so the only path that creates the System tenant is also the only // path that names it. EnsureSystemOrganization(ctx context.Context, arg EnsureSystemOrganizationParams) error // Idempotently insert the System tenant's workspace, keyed on its name // within the organization (entity-keys). The conflict target // repeats the predicate of the partial index uq_workspaces_org_id_name_ci // so Postgres can infer it. Only called when the system org has no // workspace yet. EnsureSystemWorkspace(ctx context.Context, arg EnsureSystemWorkspaceParams) error GetOrgMemberByPersonAndOrg(ctx context.Context, arg GetOrgMemberByPersonAndOrgParams) (OrgMember, error) GetOrgMembersByOrgID(ctx context.Context, orgID string) ([]GetOrgMembersByOrgIDRow, error) GetOrgType(ctx context.Context, orgType string) (OrgType, error) GetOrganizationByID(ctx context.Context, orgID string) (Organization, error) // Root-scoped key resolver (entity-keys §5): the query that makes `key` a // whole feature rather than a seed-only column. uq_organizations_key // guarantees at most one row matches; a NULL key never matches because the // parameter is compared with `=`. GetOrganizationByKey(ctx context.Context, key sql.NullString) (Organization, error) GetOrganizationsByOwner(ctx context.Context, ownerPersonID string) ([]Organization, error) GetRoleAssignmentsByPersonAndOrg(ctx context.Context, arg GetRoleAssignmentsByPersonAndOrgParams) ([]GetRoleAssignmentsByPersonAndOrgRow, error) // Natural-key resolver: the workspace of the singleton organization whose // org_type is 'system'. Returns the oldest workspace so a pre-existing // workspace (e.g. an ad-hoc seed using a different name) is adopted rather // than duplicated. GetSystemOrgWorkspace(ctx context.Context) (Workspace, error) // The singleton System organization, resolved by its natural key. Paired // with EnsureSystemOrganization; uq_organizations_one_system guarantees at // most one row matches. GetSystemOrganization(ctx context.Context) (Organization, error) GetSystemRoleByName(ctx context.Context, roleName string) (Role, error) GetWorkspaceByID(ctx context.Context, workspaceID string) (Workspace, error) // Child key resolver (entity-keys §5): the declarative address of a // workspace is its organization's key plus its own, never a name. // uq_workspaces_org_id_key guarantees at most one row matches. GetWorkspaceByOrgAndKey(ctx context.Context, arg GetWorkspaceByOrgAndKeyParams) (Workspace, error) GetWorkspacesByOrgID(ctx context.Context, orgID string) ([]Workspace, error) // Operator composite's Members section. Active members only (status='active', // excluding removed/historical rows). Defensive LIMIT 200 per design D5; // pagination is YAGNI until a real org pushes 50+ members. ListActiveMembersByOrgID(ctx context.Context, orgID string) ([]ListActiveMembersByOrgIDRow, error) // Person-detail "Org memberships" section. Returns each org the person // belongs to (active memberships only) with the org's display fields and // the person's role at that org. Sorted by joined_at DESC so the most // recent membership appears first — operators usually want "what's the // person doing now" rather than "where did they start." ListActiveMembershipsByPersonID(ctx context.Context, personID string) ([]ListActiveMembershipsByPersonIDRow, error) // Operator-facing list: excludes reserved (app-managed) org types like 'system' // so they don't render as editable cards on the Org Types management page. ListConfigurableOrgTypes(ctx context.Context) ([]OrgType, error) ListOrgTypes(ctx context.Context) ([]OrgType, error) ListOrganizations(ctx context.Context) ([]Organization, error) ListOrganizationsByType(ctx context.Context, orgType string) ([]Organization, error) // Organizations list operator surface (operator-list-scale UX-4): the // paged, searched, org-type-filtered successor to ListOrganizationsWithOwner // -- each row still carries its owner's display name so no organization can // read as unowned (ux-honest-surfaces UX-16). owner_person_id is NOT NULL // (every organization has an owner person, the System tenant included -- // 00001_init.sql), so the LEFT JOIN is defensive rather than expected to // ever drop the owner's name. // // sqlc.narg(q): NULL matches every row; set, a case-insensitive substring // match against the organization's name, or its owner's display // name or primary email (operator-list-scale: "carries a scoped // server-side search" -- "organizations: name and owner name or // email"). // sqlc.narg(org_type): NULL matches every org type; set, an exact facet // match (operator-list-scale: "Status filters exist ... organizations: org // type"). // count(*) OVER() carries the true total for the filtered set alongside // the page's rows (design D2), so the stated total never reflects only the // page. ListOrganizationsPage(ctx context.Context, arg ListOrganizationsPageParams) ([]ListOrganizationsPageRow, error) // Landing lookup's organization branch (entity-keys). Runs only // when no person matches the lookup term; a dedicated query rather than // ListOrganizationsPage because that query's owner-email term would blur // the person/organization split the lookup depends on. Active // organizations only, name substring match, bounded by LIMIT so a short // term cannot return the whole table. SearchOrganizationsByName(ctx context.Context, arg SearchOrganizationsByNameParams) ([]SearchOrganizationsByNameRow, error) UpdateOrgTypeDefaultPlanLadder(ctx context.Context, arg UpdateOrgTypeDefaultPlanLadderParams) (OrgType, error) } var _ Querier = (*Queries)(nil)