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