Hi guys, I just updated from v5.0.23 > v5.0.47 and wanted to make public some notes for reference. I couldn’t find anything on official update procedure so I hacked through it using what I remembered from the various installs I’d done. Ok, onwards…
Ensure distro environment is up to date
sudo aptitude update
sudo aptitude upgrade
Backup database
mysqldump -u root -p db_ninja --single-transaction --quick --lock-tables=false > ~/ninjabackups/ninjadb.sql
Backup ninja root directory
sudo cp -R /var/www/example.com ~/ninjabackups/example.com
Reset any changes to local Git project files. If you have knowingly made config changes you want to keep, you can do git-stash.
sudo git reset --hard
Pull the current files from the branch you’re using, v5-stable is currently the branch best suited to production afaik.
sudo git pull origin v5-stable
Set ownership and permissions on the new files
sudo chown -R www-data:www-data /var/www/example.com/invoiceninja
sudo chmod -R g+wrx /var/www/example.com/invoiceninja
Install/upgrade dependencies
composer install --no-interaction
npm i
If you get “N high severity vulnerability”, run the auto-fix command
npm audit fix --force
Reset permissions for production
sudo chown -R www-data:www-data /var/www/example.com
sudo find /var/www/example.com -type d -exec chmod 755 {} \;
sudo find /var/www/example.com -type f -exec chmod 644 {} \;
sudo find /var/www/example.com/invoiceninja/node_modules -type f -exec chmod 744 {} \;
Here I re-cached the config and the front end cache
sudo php artisan optimize
https://you.url.com?clear_cache=true
But I encountered a 500 error which after enabling debug logging in the .env, turned out to be IN referencing a MariaDB column which didn’t exist. This was my main fear - the DB structure had changed. Luckily, it was an easy fix. I dropped the database and created a new empty one:
mysql -u root -p
DROP database db_ninja;
CREATE database db_ninja;
Then I populated the DB by reloading the IN page in browser. Then reimported the DB export I backed up at the beginning:
mysql -u root -p db_ninja < ~/ninjabackups/ninjadb.sql
I reloaded the IN page in browser and encountered a ‘Deserialisation’ error:
“Error :: ‘[{id: 4, capital: Kabul, citizenship: Afghan, country_code: 004, currency: af…’ to ‘minified:x<minified:iW >’ failed due to: Deserializing '[id, 4,…[error continues]”
This solved my problem:
php artisan migrate
Followed by another URL cache clear:
https://you.url.com?clear_cache=true
I reloaded the IN page and I was then able to log in and see all my data where it should be. The health check referenced a PhantonJS warning (I’m using headless Chrome) so after finding the solution here, I realized my .env was (old?) incomplete and specifically missing the entry: “PHANTOMJS_PDF_GENERATION” so I copied a fresh .env from .env.example and updated it with my config and keys plus the PhantomJS entry to clear the healthcheck warning.
PHANTOMJS_PDF_GENERATION=false
…and so far so good Everything that worked before, still seems to be working. If anybody has a more streamlined method for Git updates, preferably without the errors, please let me know. Also if anybody has info on the ‘update’ button in the GUI, I’d love to know if it can be utilised. Peace.