Do AI Agents Need a Semantic Layer?Livestream August 26

Skip to main content

MD_GET_DIVE_VERSION

Returns a single version of a Dive, including its component code. Use this to read the code that was live at an earlier point, or to restore it by passing it back to MD_UPDATE_DIVE_CONTENT.

Syntax

SELECT * FROM MD_GET_DIVE_VERSION(
id := '<dive_id>',
version := <n>
);

Parameters

ParameterTypeRequiredDescription
idUUIDYesIdentifier of the Dive.
versionUINTEGERYesThe version to fetch. Version numbers start at 1 and increment on each content update.

Return columns

ColumnTypeDescription
idUUIDIdentifier of the version (not the Dive).
versionUINTEGERThe version number.
storage_urlVARCHARInternal storage location of the version's content.
descriptionVARCHARDescription attached to the version, or NULL.
created_atTIMESTAMP WITH TIME ZONEWhen the version was created.
api_versionUINTEGERDive API version of the content.
required_resourcesLIST(STRUCT(name VARCHAR, alias VARCHAR, url VARCHAR, id UUID, resource_type VARCHAR))Databases and shares this version queries.
contentVARCHARThe JSX/React source of this version.

Examples

Read the first version's code:

SELECT version, content
FROM MD_GET_DIVE_VERSION(
id := '80000000-0000-0000-0000-000000000001',
version := 1
);

Roll back by republishing an older version's content. Function arguments accept literals and getvariable() calls, but not subqueries or lateral column references. Store the old content in a SQL variable, then pass it back with getvariable():

-- Step 1: read the content to restore into a SQL variable
SET VARIABLE rollback_content = (
SELECT content
FROM MD_GET_DIVE_VERSION(id := '<dive_id>', version := 2)
);

-- Step 2: republish it as a new version
SELECT version
FROM MD_UPDATE_DIVE_CONTENT(
id := '<dive_id>',
content := getvariable('rollback_content'),
description := 'Roll back to version 2'
);