From 88d68a6eb895082a3f5d8d0ae18863aba525b3f9 Mon Sep 17 00:00:00 2001 From: Ewan Cahen Date: Wed, 20 Nov 2024 11:54:19 +0100 Subject: [PATCH 1/4] fix: upgrade Postgres from 15.7 to 15.9 --- database/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/Dockerfile b/database/Dockerfile index 9ab9bf32d..84a09ae42 100644 --- a/database/Dockerfile +++ b/database/Dockerfile @@ -3,7 +3,7 @@ # # SPDX-License-Identifier: Apache-2.0 -FROM postgres:15.7 +FROM postgres:15.9 RUN chmod a+rwx /docker-entrypoint-initdb.d COPY --chown=postgres:postgres *.sh /docker-entrypoint-initdb.d/ COPY --chown=postgres:postgres *.sql /docker-entrypoint-initdb.d/ From 7a932fdd6c184a47494f981c7cd27a530b70d414 Mon Sep 17 00:00:00 2001 From: Ewan Cahen Date: Wed, 20 Nov 2024 12:01:52 +0100 Subject: [PATCH 2/4] fix: upgrade PostgREST from v12.2.2 to v12.2.3 --- backend-postgrest/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend-postgrest/Dockerfile b/backend-postgrest/Dockerfile index 871278358..1a9217d3b 100644 --- a/backend-postgrest/Dockerfile +++ b/backend-postgrest/Dockerfile @@ -4,4 +4,4 @@ # # SPDX-License-Identifier: Apache-2.0 -FROM postgrest/postgrest:v12.2.2 +FROM postgrest/postgrest:v12.2.3 From e98c5fd7ccd758218ac1da547481ce126edede2f Mon Sep 17 00:00:00 2001 From: Ewan Cahen Date: Tue, 19 Nov 2024 16:00:00 +0100 Subject: [PATCH 3/4] feat: add database functions that show all categories of software and projects --- database/014-create-keyword-and-category.sql | 29 ++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/database/014-create-keyword-and-category.sql b/database/014-create-keyword-and-category.sql index e9d3e971e..134ccdf21 100644 --- a/database/014-create-keyword-and-category.sql +++ b/database/014-create-keyword-and-category.sql @@ -233,6 +233,7 @@ $$; -- includes organisation, community and general categories -- Note! to filter specific categories of an community or organisation use join with community table +-- if you ever change this table, then software_of_category() needs to be changed as well CREATE TABLE category_for_software ( software_id UUID REFERENCES software (id), category_id UUID REFERENCES category (id), @@ -260,6 +261,8 @@ $$; -- TABLE FOR project categories -- currently used only for organisation categories + +-- if you ever change this table, then projects_of_category() needs to be changed as well CREATE TABLE category_for_project ( project_id UUID REFERENCES project (id), category_id UUID REFERENCES category (id), @@ -298,3 +301,29 @@ $$ ELSE '[]'::json END AS result $$; + + +CREATE FUNCTION software_of_category() +RETURNS SETOF category_for_software +LANGUAGE SQL STABLE AS +$$ +SELECT DISTINCT software.id, category_path.id +FROM software +INNER JOIN category_for_software + ON software.id = category_for_software.software_id +INNER JOIN category_path(category_for_software.category_id) + ON TRUE; +$$; + + +CREATE FUNCTION projects_of_category() +RETURNS SETOF category_for_project +LANGUAGE SQL STABLE AS +$$ +SELECT DISTINCT project.id, category_path.id +FROM project +INNER JOIN category_for_project + ON project.id = category_for_project.project_id +INNER JOIN category_path(category_for_project.category_id) + ON TRUE; +$$; From f338f426d16ef8f628a701ed9a5be18c615720bc Mon Sep 17 00:00:00 2001 From: Ewan Cahen Date: Wed, 20 Nov 2024 15:19:48 +0100 Subject: [PATCH 4/4] build: bump database version --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 80a6e1e13..bd66a0a04 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,7 +16,7 @@ version: "3.0" services: database: build: ./database - image: rsd/database:2.5.0 + image: rsd/database:2.6.0 ports: # enable connection from outside (development mode) - "5432:5432"