[GH-ISSUE #311] how to upgrade to latest version and migrate db? #244

Closed
opened 2026-02-25 21:31:31 +03:00 by kerem · 13 comments
Owner

Originally created by @jjkonway on GitHub (Feb 23, 2021).
Original GitHub issue: https://github.com/ciur/papermerge/issues/311

Hello.

How can I upgrade to the latest version and transfer my files and accounts? i have tried setting up a new project & environment and simply transferring over the media folder and DB file, this worked for version 1.5.5 but caused many issues in 2.0. Im assuming there is a better way to upgrade? Any suggestions greatly appreciated!

papermerge 1.5.3.
Ubuntu 20.04
sqllite 3
gunicorn/nginx

Originally created by @jjkonway on GitHub (Feb 23, 2021). Original GitHub issue: https://github.com/ciur/papermerge/issues/311 Hello. How can I upgrade to the latest version and transfer my files and accounts? i have tried setting up a new project & environment and simply transferring over the media folder and DB file, this worked for version 1.5.5 but caused many issues in 2.0. Im assuming there is a better way to upgrade? Any suggestions greatly appreciated! papermerge 1.5.3. Ubuntu 20.04 sqllite 3 gunicorn/nginx
kerem 2026-02-25 21:31:31 +03:00
Author
Owner

@ciur commented on GitHub (Feb 24, 2021):

Hi,

@jjkonway, can you please be more specific about what issues you had during upgrade?

<!-- gh-comment-id:784982488 --> @ciur commented on GitHub (Feb 24, 2021): Hi, @jjkonway, can you please be more specific about what issues you had during upgrade?
Author
Owner

@l4rm4nd commented on GitHub (Feb 25, 2021):

I've also had some issues upgrading from version 1.5.5 to 2.0. The docker logs threw some Django errors like

django.db.utils.OperationalError: no such column: core_page.hocr_step_0

I removed the old database and re-deployed the container. It then instantly worked. This may not be an acceptable workaround for people that regularly use Papermerge and have a ton of documents in the database. Maybe this is what @jjkonway meant ... a proper way to migrate the database to work for version 2.0.

@ciur: BTW, the new UI looks incredible. Really good job, keep up your amazing work!

<!-- gh-comment-id:786236470 --> @l4rm4nd commented on GitHub (Feb 25, 2021): I've also had some issues upgrading from version 1.5.5 to 2.0. The docker logs threw some Django errors like ```` django.db.utils.OperationalError: no such column: core_page.hocr_step_0 ````` I removed the old database and re-deployed the container. It then instantly worked. This may not be an acceptable workaround for people that regularly use Papermerge and have a ton of documents in the database. Maybe this is what @jjkonway meant ... a proper way to migrate the database to work for version 2.0. @ciur: BTW, the new UI looks incredible. Really good job, keep up your amazing work!
Author
Owner

@TheOnlyMatty commented on GitHub (Feb 26, 2021):

Also had this issue when upgrading to 2.0. Tried the steps from reddit but ran into this error which may be of use.
django.db.migrations.exceptions.InconsistentMigrationHistory: Migration core.0033_auto_20201119_0032 is applied before its dependency core.0032_auto_20201118_1628 on database 'default'.

<!-- gh-comment-id:786336624 --> @TheOnlyMatty commented on GitHub (Feb 26, 2021): Also had this issue when upgrading to 2.0. Tried the steps from reddit but ran into this error which may be of use. `django.db.migrations.exceptions.InconsistentMigrationHistory: Migration core.0033_auto_20201119_0032 is applied before its dependency core.0032_auto_20201118_1628 on database 'default'.`
Author
Owner

@ciur commented on GitHub (Feb 26, 2021):

@TheOnlyMatty, @l4rm4nd, @jjkonway please help me understand what are the general steps to upgrade application XYZ docker.
I googled around "how to update docker iage and container" and found this. Is "sort of this" procedure you follow ?

I am sorry for (maybe) dump question, but I don't use docker for production.

<!-- gh-comment-id:786462154 --> @ciur commented on GitHub (Feb 26, 2021): @TheOnlyMatty, @l4rm4nd, @jjkonway please help me understand what are the general steps to upgrade application XYZ docker. I googled around "how to update docker iage and container" and found [this](https://phoenixnap.com/kb/update-docker-image-container). Is "sort of this" procedure you follow ? I am sorry for (maybe) dump question, but I don't use docker for production.
Author
Owner

@l4rm4nd commented on GitHub (Feb 26, 2021):

@TheOnlyMatty, @l4rm4nd, @jjkonway please help me understand what are the general steps to upgrade application XYZ docker.
I googled around "how to update docker iage and container" and found this. Is "sort of this" procedure you follow ?

I am sorry for (maybe) dump question, but I don't use docker for production.

For docker containers, one usually utilizes volumes to persistently store data. You basically link an internal docker container path like /data to your host server's storage path like /mnt/papermerge or so. Your papermerge files (data & config) are then persistently saved on your server and survive a restart or re-deployment of the docker container itself. This includes the database papermege.db.

image

Example docker cli command to start papermege docker container by linuxserver.io

image

Upgrading version 1.5.5 to 2.0 is just a matter of pulling the newest docker image from e.g. linuxserver.io dockerhub and "restarting" your container. All previous settings and your stored data via docker volumes will be used again for the new container version.

The crux here seems to be that the new version 2.0 wants some database changes to run properly. However, the newest 2.0 release does not correctly migrate these changes to the "old" 1.5.5 database.

By removing the old papermege.db database and restarting the container, a new database is created and papermerge 2.0 works properly. Might be an issue with the linuxserver.io docker image, I don't know.

<!-- gh-comment-id:786495182 --> @l4rm4nd commented on GitHub (Feb 26, 2021): > @TheOnlyMatty, @l4rm4nd, @jjkonway please help me understand what are the general steps to upgrade application XYZ docker. > I googled around "how to update docker iage and container" and found [this](https://phoenixnap.com/kb/update-docker-image-container). Is "sort of this" procedure you follow ? > > I am sorry for (maybe) dump question, but I don't use docker for production. For docker containers, one usually utilizes volumes to persistently store data. You basically link an internal docker container path like /data to your host server's storage path like /mnt/papermerge or so. Your papermerge files (data & config) are then persistently saved on your server and survive a restart or re-deployment of the docker container itself. This includes the database `papermege.db`. ![image](https://user-images.githubusercontent.com/21357789/109275673-57f12580-7815-11eb-9e9a-06881128ccb9.png) Example docker cli command to start papermege docker container by linuxserver.io ![image](https://user-images.githubusercontent.com/21357789/109274831-393e5f00-7814-11eb-86c8-c1ffc8ca9198.png) Upgrading version 1.5.5 to 2.0 is just a matter of pulling the newest docker image from e.g. linuxserver.io dockerhub and "restarting" your container. All previous settings and your stored data via docker volumes will be used again for the new container version. The crux here seems to be that the new version 2.0 wants some database changes to run properly. However, the newest 2.0 release does not correctly migrate these changes to the "old" 1.5.5 database. By removing the old `papermege.db` database and restarting the container, a new database is created and papermerge 2.0 works properly. Might be an issue with the linuxserver.io docker image, I don't know.
Author
Owner

@w4tzmann commented on GitHub (Feb 26, 2021):

Hey @ciur ,

the way i tried to update my docker-compose setup was:
docker-compse down
docker-compose pull
cocker-compose up -d

In the docker-compose.yml file i mostly use the 'latest' tag, so when i pull new images from docker-hub I get a new version.
papermarge 'latest' tag is still 1.5.5 so i changed the tag to '2.0.0.rc35' and tried the steps above again.

Which then leads to the error with the not updated database schema.

After reading the newest reddit posts, i found this

Trying to run './manage.py migrate' in the papermerge_worker container bring me this error:
Traceback (most recent call last):

  File "./manage.py", line 24, in <module>
    execute_from_command_line(sys.argv)
  File "/opt/app/.venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/opt/app/.venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/opt/app/.venv/lib/python3.8/site-packages/django/core/management/base.py", line 330, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/opt/app/.venv/lib/python3.8/site-packages/django/core/management/base.py", line 371, in execute
    output = self.handle(*args, **options)
  File "/opt/app/.venv/lib/python3.8/site-packages/django/core/management/base.py", line 85, in wrapped
    res = handle_func(*args, **kwargs)
  File "/opt/app/.venv/lib/python3.8/site-packages/django/core/management/commands/migrate.py", line 95, in handle
    executor.loader.check_consistent_history(connection)
  File "/opt/app/.venv/lib/python3.8/site-packages/django/db/migrations/loader.py", line 302, in check_consistent_history
    raise InconsistentMigrationHistory(
django.db.migrations.exceptions.InconsistentMigrationHistory: Migration core.0033_auto_20201119_0032 is applied before its dependency core.0032_auto_20201118_1628 on database 'default'.

I fear I'm out now, because I have absolute no clue on Python :D

<!-- gh-comment-id:786586665 --> @w4tzmann commented on GitHub (Feb 26, 2021): Hey @ciur , the way i tried to update my docker-compose setup was: docker-compse down docker-compose pull cocker-compose up -d In the docker-compose.yml file i mostly use the 'latest' tag, so when i pull new images from docker-hub I get a new version. papermarge 'latest' tag is still 1.5.5 so i changed the tag to '2.0.0.rc35' and tried the steps above again. Which then leads to the error with the not updated database schema. After reading the newest reddit posts, i found [this](https://www.reddit.com/r/Papermerge/comments/ls7dq3/new_update_broke_my_instance_docker/) Trying to run './manage.py migrate' in the papermerge_worker container bring me this error: Traceback (most recent call last): ``` File "./manage.py", line 24, in <module> execute_from_command_line(sys.argv) File "/opt/app/.venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line utility.execute() File "/opt/app/.venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 395, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/opt/app/.venv/lib/python3.8/site-packages/django/core/management/base.py", line 330, in run_from_argv self.execute(*args, **cmd_options) File "/opt/app/.venv/lib/python3.8/site-packages/django/core/management/base.py", line 371, in execute output = self.handle(*args, **options) File "/opt/app/.venv/lib/python3.8/site-packages/django/core/management/base.py", line 85, in wrapped res = handle_func(*args, **kwargs) File "/opt/app/.venv/lib/python3.8/site-packages/django/core/management/commands/migrate.py", line 95, in handle executor.loader.check_consistent_history(connection) File "/opt/app/.venv/lib/python3.8/site-packages/django/db/migrations/loader.py", line 302, in check_consistent_history raise InconsistentMigrationHistory( django.db.migrations.exceptions.InconsistentMigrationHistory: Migration core.0033_auto_20201119_0032 is applied before its dependency core.0032_auto_20201118_1628 on database 'default'. ``` I fear I'm out now, because I have absolute no clue on Python :D
Author
Owner

@DrVanSteiner commented on GitHub (Feb 26, 2021):

The same error occurs on the automatic migration...

<!-- gh-comment-id:786687559 --> @DrVanSteiner commented on GitHub (Feb 26, 2021): The same error occurs on the automatic migration...
Author
Owner

@ciur commented on GitHub (Feb 26, 2021):

I am on it. I will come back with updates soon.

<!-- gh-comment-id:786767342 --> @ciur commented on GitHub (Feb 26, 2021): I am on it. I will come back with updates soon.
Author
Owner

@ciur commented on GitHub (Feb 27, 2021):

I found the problem. It has nothing to do with docker. The issue is with migration dependencies (i.e. the order in which database changes are applied).
The fix that I will provide will work ONLY if you use latest stable release i.e. version 1.5.5.
Please upgrade to 1.5.5 first.

<!-- gh-comment-id:787029447 --> @ciur commented on GitHub (Feb 27, 2021): I found the problem. It has nothing to do with docker. The issue is with migration dependencies (i.e. the order in which database changes are applied). The fix that I will provide will work ONLY if you use latest stable release i.e. version 1.5.5. Please upgrade to 1.5.5 first.
Author
Owner

@ciur commented on GitHub (Feb 27, 2021):

Migration dependencies were little chaotic. The problem was fixed.

I will fix XSS issues reported for 2.0 and then I will tag a new release. With above mentioned fix you shouldn't have any problem upgrading from 1.5.5 to 2.0.

<!-- gh-comment-id:787045114 --> @ciur commented on GitHub (Feb 27, 2021): Migration dependencies were little chaotic. The problem [was fixed](https://github.com/papermerge/papermerge-core/commit/bf90d59578fde2fd54ec68220efd139ca008dd6f). I will fix XSS issues reported for 2.0 and then I will tag a new release. With above mentioned fix you shouldn't have any problem upgrading from 1.5.5 to 2.0.
Author
Owner

@ciur commented on GitHub (Feb 27, 2021):

all reported xss problems + migration issue were fixed. I will release tomorrow (next iteration of) release candidate.

<!-- gh-comment-id:787098518 --> @ciur commented on GitHub (Feb 27, 2021): all reported xss problems + migration issue were fixed. I will release tomorrow (next iteration of) release candidate.
Author
Owner

@ciur commented on GitHub (Feb 28, 2021):

@w4tzmann, release 2.0.0rc38 is out.

You may want to try docker image provided by linuxserver.io - which is tagged v2.0.0rc38-ls28
Or
official image

I tested upgrade 1.5.5 -> 2.0.0rc38 and it worked.

<!-- gh-comment-id:787412743 --> @ciur commented on GitHub (Feb 28, 2021): @w4tzmann, [release 2.0.0rc38 ](https://github.com/ciur/papermerge/releases/tag/v2.0.0rc38) is out. You may want to try docker [image provided by linuxserver.io](https://github.com/linuxserver/docker-papermerge/releases/tag/v2.0.0rc38-ls28) - which is tagged v2.0.0rc38-ls28 Or [official image](https://hub.docker.com/r/eugenci/papermerge) I tested upgrade 1.5.5 -> 2.0.0rc38 and it worked.
Author
Owner

@w4tzmann commented on GitHub (Feb 28, 2021):

@ciur thank you! Offical image is working for me now!

<!-- gh-comment-id:787429107 --> @w4tzmann commented on GitHub (Feb 28, 2021): @ciur thank you! Offical image is working for me now!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/papermerge#244
No description provided.