pub(super) fn apply_catalog_patch_release(
client: &Client,
catalog_path: &Path,
catalog_temp_path: &Path,
metadata_temp_path: &Path,
patch_urls: &[String],
expected_hash: &str,
previous_hash: &str,
) -> Result<()>Expand description
Applies one or more SQL patch files to an existing catalog database.
This is the incremental refresh path used when the update API returns a patch plan. The function works on a temporary copy of the current catalog, applies each patch URL in order, verifies the database integrity, rebuilds catalog metadata, and validates the final catalog hash before writing the updated metadata JSON.
§Workflow
- Confirm that the source catalog already exists.
- Copy the source catalog to the temporary patch working copy.
- Open the working copy with foreign keys enabled and
DELETEjournaling. - Download and decompress each patch URL as zstd-compressed SQL.
- Execute each patch sequentially against the working copy.
- Run
PRAGMA integrity_checkto verify the patched database. - Rebuild metadata from the patched database state.
- Verify the patched database hash matches the rebuilt metadata hash.
- Write the refreshed metadata JSON to
metadata_temp_path.
§Errors
Returns an error when the source catalog is missing, when the working copy cannot be created or opened, when any patch download or SQL execution fails, when the integrity check fails, when hash verification fails, or when metadata serialization or writing fails.
§Safety
The source catalog_path is never modified directly. All patching happens
on the temporary working copy, which the caller finalizes separately.