-- Keep existing meeting requests in sync when their linked summary was already submitted.
UPDATE "meeting_requests" AS "request"
SET "status" = 'COMPLETED'::"MeetingRequestStatus"
FROM "meeting_summaries" AS "summary"
INNER JOIN "meeting_summary_statuses" AS "summary_status"
  ON "summary_status"."id" = "summary"."meeting_summary_status_id"
WHERE "summary"."meeting_request_id" = "request"."id"
  AND "summary"."deleted_at" IS NULL
  AND "summary_status"."deleted_at" IS NULL
  AND "summary_status"."code" = 'SUBMITTED'
  AND "request"."status" = 'SCHEDULED'::"MeetingRequestStatus";
