docs: def _write_template(upgrade_file, name, depends_on, repository, auto=False):
      """Write template to upgrade file."""
      if auto:
          # Ensure all models are loaded
          from invenio_db import models
          list(models)
          template_args = produce_upgrade_operations()
          operations_str = template_args['upgrades']
          import_str = template_args['imports']
      else:
          operations_str = "    pass"
          import_str = ""
  
      with open(upgrade_file, 'w') as f:
          f.write(UPGRADE_TEMPLATE % {
              'depends_on': depends_on,
              'repository': repository,
              'year': date.today().year,
              'operations': operations_str,
              'imports': import_str,
              'cls': ''.join(w.capitalize() or '_' for w in name.split('_'))
          })