- name: "Add missing DB indices in Nextcloud (single run)"
  ansible.builtin.shell: |
    set -e
    {{ nextcloud_docker_exec_occ }} db:add-missing-indices
  args:
    executable: /bin/bash
  vars:
    # Give the command enough time without async/poll overhead
    ansible_command_timeout: 3600
  register: db_indices_result
  failed_when: db_indices_result.rc != 0
  changed_when: >
    ('Adding additional' in (db_indices_result.stdout | default(''))) or
    ('Removing' in (db_indices_result.stdout | default(''))) or
    ('updated successfully' in (db_indices_result.stdout | default('')))