From f13107e26de9057dec03c9dc1d5f2a1a14f321e6 Mon Sep 17 00:00:00 2001 From: Pablo Gracia Gil Date: Fri, 8 Nov 2024 00:00:36 +0100 Subject: [PATCH] Add migration script --- ...07201532_add-number-of-volunteers-in-each-request.sql | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/supabase/migrations/20241107201532_add-number-of-volunteers-in-each-request.sql b/supabase/migrations/20241107201532_add-number-of-volunteers-in-each-request.sql index b9becac8..b5ee485a 100644 --- a/supabase/migrations/20241107201532_add-number-of-volunteers-in-each-request.sql +++ b/supabase/migrations/20241107201532_add-number-of-volunteers-in-each-request.sql @@ -1 +1,8 @@ -alter table "public"."help_requests" add column "asignees_count" smallint not null default '0'::smallint; \ No newline at end of file +alter table "public"."help_requests" add column "asignees_count" smallint not null default '0'::smallint; + +UPDATE "public"."help_requests" +SET "assignees_count" = ( + SELECT COUNT(*) + FROM "public"."help_request_assignments" + WHERE "public"."help_request_assignments"."help_request_id" = "public"."help_requests"."id" +); \ No newline at end of file