Replies: 3 comments 6 replies
-
I can sympathize with trying everything that comes to mind but this sounds like a lot of issues could have been solved by reading the install/update docs fully or reaching out here instead of taking non-revocable steps like touching the database. If your instance is complaining please fix that/reach out before upgrading, we are including warnings for that reason. Docker is one of the easier deployment methods and should just work - but please read the docs before upgrading. You need to run the update command after pulling a new image version. Please feel free to reach out here when the instance throws errors/warnings. |
Beta Was this translation helpful? Give feedback.
-
As I said, my instance was very old and very specific, so I did consider that being the cause of the problem. Mainly because I raised the issue in the past, and it seemed to fix the problem.... I also did think that I am pulling some development version (even though it was master) as it installed node.js, etc.... But I also really would like: Should I raise a new issue with the backup/restore stuff I posted above? |
Beta Was this translation helpful? Give feedback.
-
As an additional note here, it is not reasonable to expect "backup" and "restore" commands to succeed if there have been changes to the database schema (i.e. migrations) in the interim. You should always backup and restore from the same version. |
Beta Was this translation helpful? Give feedback.
-
I've been using InvenTree for about 4 years now, and I am quite happy with it, but for some reason the updating of it has been a chore every time I tried it. And yesterday it was even more frustrating. I've spent 5+ hours to upgrade the version from December 2023 to actual, but I am getting ahead of myself.
And btw: do not take this as a critique of Inventree, its developers or an angry rant. It is meant as just a user story....
First little background: I am using inventree on baremetal running Fedora since September 2020. The instalation was a little bit chaotic back then, and I did not have much of Django experience. But I pulled it from github, started somehow gunicorn in an virtual environment and via uswgi I managed to get it working through my nginx (that is doing the HTTP routing, TLS, etc...).
I updated it from time to time by just pulling the new version from github, invoke update, fix up the mess it made and restart the whole gunicorn/uswgi service. But more than once I had to deal with the database migration stuff not working. It was still something like:
Migration part.0104_alter_part_description is applied before its dependency part.0103_auto_20230317_0816
, only the names were different. But I've always managed to get it working, the example can be found in issue #4582 .I switched to postgres from sqlite because of some DB locking stuff ( #5936 ) and also because I hoped that it could solve this issue. This actually made the updating issue a little bit more problematic, because with sqlite I could just back up the whole Inventree directory to have a checkpoint to return to. With postgres I had to have database backups also - it is not an issue, just a thing to remember.
I also have regular backups via
invoke backup
and that made me feel safe that I will not lose my data, but little did I know that restoring it would be a little bit more difficult. But more about later.And now what happen yesterday. I did last update sometimes in December 2023, so I decided that a new update would be great... So I did
invoke backup
, stopped the uswgi/gunicorn service, didgit pull
andinvoke update
.And guess what, again the migration thing problems. I still do not understand how the migration stuff works exactly, but I know that this time it reported more problems than last time. I tried to reorder the files, so the dependencies were right, and I managed to get it happy and not complain about dependencies. However, that was a big mistake as the update process failed in the middle because of trying to remove some column that was not there.... And with that I made quite a mess in my DB, as some of the DB migration stuff was already done. After a few runs of the update and manually dropping columns so it can recreate them, I finally managed to get it done.
I have to say that the docs are not that useful in this state and this depth of problems (and I do not blame them for that), but one thing has been quite confusing for me. The docs mention invetree cli command, but I was not able to find it anywhere. This resulted in invoke commands complaining about not having the INVENTREE_STATIC_ROOT variable set (even though it is defined in the config.yaml). So I set it manually, and it started to complain about other INVENTREE.... variables. I've ended up with specifying them all by hand. While browsing the issues in here, I've discovered that this should be done by that mysterious inventree cli binary that I was not able to find. Also, why was it not needed in the past?
But after the database upgrade was done, the
invoke update
started to complain about missing yarn? So I installed yarn and it started to complain about node.js version? Well, I managed to upgrade the node.js version (there were other projects on that server using it). Somewhere in the process it also failed with some message that pointed to the fact, that I need to install jc (whatever that is).But after some time I've managed to get it done, and it seemed that it is upgraded. The only issue was that the gunicorn/uswgi service did not start for some reason. It seems that the directory structure changed and the gunicorn must be run from somewhere else than before. I managed to get it running from the command line and when I tried to access the web UI, Django said, that I am using postgress 11 and it requires 13.... I have to say that at this point I had to take a break, because I was close to r
m -rf
.With fresh head, I decided to install the new current production version and restore data from backup. That will get rid of all my weird setup from 4 years ago plagued with all my update troubles, and also make the installation a little bit more "standard". And as a bonus, maybe it will install the mysterious inventree cli binary :-) .
I decided to use the installer and see how it goes. But quite fast I've found that it supports only Ubuntu and Debian. So I was out of luck with my Fedora.
Fine, I will use docker - it will make it possible for Inventree to use whatever version of whatever it needs.... The docker installation is quite nicely described in the docs and all the docker containers' roles are described. So I've installed the docker containers via docker-compose, and started the whole thing. But for some reason, the caddy was not working for me. But I did not want to use it anyway (I already have nginx for that) so I managed to bypass it with nginx. And finally after cca 3 hours of work, I did have actual inventree back (without data). And I was not able to log in, because of django CORS setting, but that was a relatively simple thing to fix. I was feeling that I am close, all I needed is to restore the data. And I had two backups with the same data - one before the upgrade and one after the upgrade. Well, let's just say I was wrong.
I've tried the
invoke restore
with the backup, and it said something about not being able to drop an index. Fine, I've converted the postgre custom backup format to SQL to see what is going on. The funny thing is that in the SQL it tried to create that index not drop it. So I've dropped the database, recreated it and ran the import directly from the SQL via psql. And it worked! No dropping index error. I was feeling lucky, so I restarted the whole docker compose and logged into web UI. For a short glimpse I saw a few of my data, but after a few seconds it went to maintenance mode to do the database update. I did not think anything wrong about it, the backup I restored was taken before the upgrade. But to my surprise the update did not work, and I found a familiar "Migration part.0104_alter_part_description is applied before its dependency part.0103_auto_20230317_0816
" message in the update log. I have to admit this was too much for me and I really thought about quitting.But hey, I had the backup after the update, so there will be no need for this database migration shenanigans... So I dropped the database once more, recreated it, imported the data after upgrade via psql and restarted the whole inventree containers.
And I ended up with a log full of "
Failed 'part.tasks.update_part_pricing' (west-stream-fish-william) - 'override_min'
" messages. I had no idea why, the field was present in the database. I was quite frustrated, but I did not want to give up so easily. And I did get one last idea to try....Even though the server was not starting, I was able to run
docker-compose run inventree invoke
commands. And I remembered that there is the export/import data to JSON feature. So I've rundocker-compose .... invoke export
(with the DB containing the data from the backup after the upgrade). Then I completely deleted all the postgresql data,invoke update
and restarted the inventree to get it in actual but empty state. And then, finally,docker-compose ... invoke import
and it imported all the data!So for now it seems like all the data are in there (apart from access tokens) and it seems to be working. And I am looking forward to upgrading by just
docker pull
in the future, even though I fully expect my old friend "Migration something before something
" to pop up....I have no idea why updating inventree is always such a chore for me and why everything goes south every time. I've had fewer issues with more complicated systems. And also, would it be possible to add the json export to the
invoke backup
command? And maybe have aninvoke restore
flag to use it instead of the actual DB dump?Beta Was this translation helpful? Give feedback.
All reactions