UPDATE template_item
   SET content = CASE
         WHEN content LIKE '%{{quorum_statement}}%' THEN
           REPLACE(content, '{{quorum_statement}}', '{{quorum_statement}}
{{attendees_block}}')
         WHEN content LIKE '%## Protokollnotizen%' THEN
           REPLACE(content, '## Protokollnotizen', '{{attendees_block}}

## Protokollnotizen')
         ELSE
           content || '

{{attendees_block}}'
       END,
       version_label = CASE WHEN version_label IN ('v1', 'v2') THEN 'v3' ELSE version_label END,
       updated_at = NOW()
 WHERE category = 'meeting_protocol'
   AND content NOT LIKE '%{{attendees_block}}%';
