Invoice Ninja v5 Updating - Debian / Git

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/ ~/ninjabackups/

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/
sudo chmod -R g+wrx /var/www/

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/
sudo find /var/www/ -type d -exec chmod 755 {} \;
sudo find /var/www/ -type f -exec chmod 644 {} \;
sudo find /var/www/ -type f -exec chmod 744 {} \;

Here I re-cached the config and the front end cache

sudo php artisan optimize

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:

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.


…and so far so good :metal: 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.

1 Like

Thank you again, this is extremely useful!

If it’s ok with you and @david agrees I think we should move all of your content into the official docs. If you’re up for it you could submit pull requests directly but we can also handle it for you.

Just to note… in the latest version of the app you can run the git pull step in the admin portal using the about icon in the lower left corner.

Hey! Sorry, I missed your reply, I’ve been away slogging through some projects and looks like I didn’t have forum notifications on :man_facepalming: Yes please use anything in the docs you think may be of use!

Congratulations on getting a stable v5 out :champagne: I’m quite a few versions behind now so I’m excited to update and catch up on the development

1 Like