diff --git a/nixos/modules/services/monitoring/librenms.nix b/nixos/modules/services/monitoring/librenms.nix index 6e7b5b3de4c87..e3f0d486ae697 100644 --- a/nixos/modules/services/monitoring/librenms.nix +++ b/nixos/modules/services/monitoring/librenms.nix @@ -603,15 +603,10 @@ in '' ) + '' - # clear cache after update and regenerate optimizations + # clear cache after update (before migrations) OLD_VERSION=$(cat ${cfg.dataDir}/version) if [[ $OLD_VERSION != "${package.version}" ]]; then rm -r ${cfg.dataDir}/cache/* - ${artisanWrapper}/bin/librenms-artisan view:clear - ${artisanWrapper}/bin/librenms-artisan optimize:clear - ${artisanWrapper}/bin/librenms-artisan view:cache - ${artisanWrapper}/bin/librenms-artisan optimize - echo "${package.version}" > ${cfg.dataDir}/version fi # convert rrd files when the oneMinutePolling option is changed @@ -623,6 +618,15 @@ in # migrate db ${artisanWrapper}/bin/librenms-artisan migrate --force --no-interaction + + # regenerate cache after migrations after update + if [[ $OLD_VERSION != "${package.version}" ]]; then + ${artisanWrapper}/bin/librenms-artisan view:clear + ${artisanWrapper}/bin/librenms-artisan optimize:clear + ${artisanWrapper}/bin/librenms-artisan view:cache + ${artisanWrapper}/bin/librenms-artisan optimize + echo "${package.version}" > ${cfg.dataDir}/version + fi ''; };