-- Fix: non-approval form instances should not stay in PENDING_APPROVAL
UPDATE platform_form.form_instances AS fi
SET status = 'SUBMITTED',
    approval_status = NULL,
    approval_start_time = NULL,
    approval_end_time = NULL
FROM platform_form.form_definitions AS fd
WHERE fi.form_definition_id = fd.id
  AND fd.requires_approval = false
  AND fi.status = 'PENDING_APPROVAL'
  AND fi.approval_instance_id IS NULL;
