-- Keep existing meetings in sync when their linked summary was already submitted.
UPDATE "meetings" AS "meeting"
SET "status" = 'COMPLETED'::"MeetingStatus"
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_id" = "meeting"."id"
  AND "summary"."deleted_at" IS NULL
  AND "summary_status"."deleted_at" IS NULL
  AND "summary_status"."code" = 'SUBMITTED';
