diff --git a/.env.example b/.env.example index 945630c57..0faa74cc1 100644 --- a/.env.example +++ b/.env.example @@ -30,3 +30,5 @@ MAIL_FROM_NAME=null MAIL_FROM_ADDRESS=null FIREWALL_ENABLED=false + +MODEL_CACHE_ENABLED=false diff --git a/.env.testing b/.env.testing index 06665a5c2..60ecb874e 100644 --- a/.env.testing +++ b/.env.testing @@ -24,3 +24,5 @@ MAIL_PASSWORD=null MAIL_ENCRYPTION=null FIREWALL_ENABLED=false + +MODEL_CACHE_ENABLED=false diff --git a/app/Console/Commands/FinishUpdate.php b/app/Console/Commands/FinishUpdate.php index 87b0f432b..a25f2a00a 100644 --- a/app/Console/Commands/FinishUpdate.php +++ b/app/Console/Commands/FinishUpdate.php @@ -62,6 +62,9 @@ class FinishUpdate extends Command session(['company_id' => $company_id]); setting()->setExtraColumns(['company_id' => $company_id]); + // Disable model cache during update + config(['laravel-model-caching.enabled' => false]); + event(new UpdateFinished($alias, $new, $old)); } } diff --git a/app/Listeners/Update/V20/Version200.php b/app/Listeners/Update/V20/Version200.php index 7aac278de..82f8f417d 100644 --- a/app/Listeners/Update/V20/Version200.php +++ b/app/Listeners/Update/V20/Version200.php @@ -994,6 +994,7 @@ class Version200 extends Listener 'QUEUE_CONNECTION' => 'sync', 'LOG_CHANNEL' => 'stack', 'FIREWALL_ENABLED' => 'true', + 'MODEL_CACHE_ENABLED' => 'true', ]); } } diff --git a/app/Utilities/Installer.php b/app/Utilities/Installer.php index 6956e150f..9ee2f0cf0 100644 --- a/app/Utilities/Installer.php +++ b/app/Utilities/Installer.php @@ -254,10 +254,11 @@ class Installer { // Update .env file static::updateEnv([ - 'APP_LOCALE' => session('locale'), - 'APP_INSTALLED' => 'true', - 'APP_DEBUG' => 'false', - 'FIREWALL_ENABLED' => 'true', + 'APP_LOCALE' => session('locale'), + 'APP_INSTALLED' => 'true', + 'APP_DEBUG' => 'false', + 'FIREWALL_ENABLED' => 'true', + 'MODEL_CACHE_ENABLED' => 'true', ]); // Rename the robots.txt file diff --git a/config/laravel-model-caching.php b/config/laravel-model-caching.php index 44aab632f..57865442f 100644 --- a/config/laravel-model-caching.php +++ b/config/laravel-model-caching.php @@ -2,10 +2,10 @@ return [ - 'cache-prefix' => env('MODEL_CACHE_PREFIX', 'model'), - 'enabled' => env('MODEL_CACHE_ENABLED', true), + 'cache-prefix' => env('MODEL_CACHE_PREFIX', 'model'), + 'use-database-keying' => env('MODEL_CACHE_USE_DATABASE_KEYING', true), 'store' => env('MODEL_CACHE_STORE', 'array'), diff --git a/overrides/akaunting/module/Commands/InstallCommand.php b/overrides/akaunting/module/Commands/InstallCommand.php index f252762df..ffcc216fb 100644 --- a/overrides/akaunting/module/Commands/InstallCommand.php +++ b/overrides/akaunting/module/Commands/InstallCommand.php @@ -62,6 +62,9 @@ class InstallCommand extends Command $this->call('cache:clear'); + // Disable model cache during installation + config(['laravel-model-caching.enabled' => false]); + // Update database $this->call('migrate', ['--force' => true]);