apiVersion: batch/v1
kind: Job
metadata:
  name: jellyfin-enable-wal
  namespace: media
spec:
  ttlSecondsAfterFinished: 600
  template:
    spec:
      restartPolicy: Never
      containers:
      - name: enable-wal
        image: alpine:latest
        command:
        - sh
        - -c
        - |
          apk add --no-cache sqlite
          echo "Enabling WAL mode on jellyfin.db..."
          sqlite3 /config/data/jellyfin.db "PRAGMA journal_mode=WAL;"
          echo "Verifying WAL mode..."
          sqlite3 /config/data/jellyfin.db "PRAGMA journal_mode;"
          echo "WAL mode enabled successfully!"
        volumeMounts:
        - name: jellyfin-data
          mountPath: /config
      volumes:
      - name: jellyfin-data
        persistentVolumeClaim:
          claimName: jellyfin-config
