From ff4214fabdc7814498cbaf2c14a2d5642cbc5187 Mon Sep 17 00:00:00 2001 From: Ratchanan Srirattanamet Date: Sat, 19 Apr 2025 15:42:28 +0000 Subject: [PATCH] nixos/kimai: fix upgrading to Kimai 2.32 by clearing cache earlier During testing of Kimai 2.32, it's been found that fixes done in PR 371917 [^1] is not enough to prevent error in the case of upgrading from 2.31 to 2.32. Hinted by an upstream issue [^2], make sure that the cache is cleared before running `kimai:install`, not after. This fixes upgrading from 2.31 to 2.32, and should prevent similar issue from popping up again. [^1]: https://github.com/NixOS/nixpkgs/pull/371917 [^2]: https://github.com/kimai/kimai/issues/5437 --- nixos/modules/services/web-apps/kimai.nix | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/nixos/modules/services/web-apps/kimai.nix b/nixos/modules/services/web-apps/kimai.nix index 47e1dfc20981..4ca464489b47 100644 --- a/nixos/modules/services/web-apps/kimai.nix +++ b/nixos/modules/services/web-apps/kimai.nix @@ -324,12 +324,14 @@ in ${pkg hostName cfg}/bin/console lint:yaml --parse-tags \ ${pkg hostName cfg}/share/php/kimai/config - # Run kimai:install to ensure database is created or updated. + # Before running any further console commands, clear cache. This + # avoids errors due to old cache getting used with new version + # of Kimai. + ${pkg hostName cfg}/bin/console cache:clear --env=prod + # Then, run kimai:install to ensure database is created or updated. # Note that kimai:update is an alias to kimai:install. ${pkg hostName cfg}/bin/console kimai:install --no-cache - # Clear cache and warmup cache separately, to avoid "Cannot declare - # class App\Entity\Timesheet" error on first init after upgrade. - ${pkg hostName cfg}/bin/console cache:clear --env=prod + # Finally, warm up cache. ${pkg hostName cfg}/bin/console cache:warmup --env=prod '';