Skip to main content

MD_UPDATE_DIVE_STATUS

Sets the status of an existing Dive. The status is recorded against a specific version of the Dive; later content updates don't change it.

Syntax

SELECT * FROM MD_UPDATE_DIVE_STATUS(
id ='your-dive-uuid'::UUID,
status ='ready'
);

Parameters

ParameterTypeRequiredDescription
idUUIDYesThe unique identifier of the Dive
statusVARCHARYesOne of draft, ready, endorsed, or archived
versionUINTEGERNoThe reviewed version the status applies to. Defaults to the Dive's current version.

Permissions

Owners can set draft, ready, or archived on their own Dives. Organization admins can set any status on any Dive in the organization, and only admins can set endorsed.

Return columns

Returns the updated Dive summary.

ColumnTypeDescription
idUUIDUnique identifier of the Dive
titleVARCHARDive title
descriptionVARCHARDive description
owner_idUUIDUUID of the Dive owner
current_versionINTEGERLatest version number (1-based)
created_atTIMESTAMP WITH TIME ZONEWhen the Dive was created
updated_atTIMESTAMP WITH TIME ZONEWhen the Dive was last updated
owner_nameVARCHARName of the Dive owner
statusVARCHARThe Dive's status
status_changed_atTIMESTAMP WITH TIME ZONEWhen the status was last set
status_set_byUUIDUUID of the user who set the status
status_applies_to_versionUINTEGERThe version the status was set against

Examples

Mark a Dive as ready for others to use:

SELECT id, title, status, status_applies_to_version
FROM MD_UPDATE_DIVE_STATUS(
id ='a1b2c3d4-e5f6-7890-abcd-ef1234567890'::UUID,
status ='ready'
);

Endorse a specific reviewed version (requires an organization admin):

SELECT *
FROM MD_UPDATE_DIVE_STATUS(
id ='a1b2c3d4-e5f6-7890-abcd-ef1234567890'::UUID,
status ='endorsed',
version =3
);

Errors

  • Returns an error if the Dive does not exist or you don't own it (and aren't an admin).
  • Returns an error if status isn't one of the four valid values.
  • Returns an authorization error if a non-admin sets endorsed.
  • Returns an error if version doesn't exist for the Dive.