Database restoration fails due to hotfix in production
The database restoration of RSD production currently fails due to a hotfix applied to category_path
(see upstream#1297):
DROP FUNCTION category_path;
CREATE FUNCTION category_path(category_id UUID)
RETURNS TABLE (
id UUID,
parent UUID,
community UUID,
short_name VARCHAR,
name VARCHAR,
properties JSONB,
provenance_iri VARCHAR
)
LANGUAGE SQL STABLE AS
$$
WITH RECURSIVE cat_path AS (
SELECT *, 1 AS r_index
FROM category WHERE id = category_id
UNION ALL
SELECT category.*, cat_path.r_index+1
FROM category
JOIN cat_path
ON category.id = cat_path.parent
)
-- 1. How can we reverse the output rows without injecting a new column (r_index)?
-- 2. How a table row "type" could be used here Now we have to list all columns of `category` explicitly
-- I want to have something like `* without 'r_index'` to be independent from modifications of `category`
-- 3. Maybe this could be improved by using SEARCH keyword.
SELECT id, parent, community, short_name, name, properties, provenance_iri
FROM cat_path
ORDER BY r_index DESC;
$$;
Previously, category_path
was defined as:
CREATE FUNCTION category_path(category_id UUID)
RETURNS TABLE (LIKE category)
LANGUAGE SQL STABLE
The current image v2.19.0-hifis1
uses the latter definition. To be able to test the migrations, the database needs to be initialised with the hotfix applied.