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​

Requires permissionRoles and access control →
Update organization-wide Dive statusesAdmin ✓Builder —Explorer —

Marked preset roles include the permission by default; a custom role qualifies when it inherits a role that includes it. Owners can set draft, ready, or archived on their own Dives without this permission. Any status on any Dive, including endorsed, requires it.

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. This requires permission to update organization-wide Dive statuses:

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 don't have permission to update organization-wide Dive statuses.
  • Returns an error if status isn't one of the four valid values.
  • Returns an authorization error if you set endorsed without permission to update organization-wide Dive statuses.
  • Returns an error if version doesn't exist for the Dive.