InvenTree icon indicating copy to clipboard operation
InvenTree copied to clipboard

Error after SQLITE3 to PGSQL Migration and Update Server

Open IT-META opened this issue 11 months ago • 3 comments

Please verify that this bug has NOT been raised before.

  • [x] I checked and didn't find a similar issue

Describe the bug*

Hello,

I have migrate my Inventree Instance from SQLITE3 to PGSQL and all seems OK.

I have running "apt upgrade" to update my OS and my Inventree instance.

When I reconnect, i have lost many informations. The error log say:

relation "common_inventreecustomuserstatemodel" does not exist LINE 1: ...treecustomuserstatemodel"."reference_status" FROM "common_in...

**Traceback (most recent call last):

File "/opt/inventree/env/lib/python3.9/site-packages/django/db/backends/utils.py", line 89, in _execute return self.cursor.execute(sql, params)

psycopg2.errors.UndefinedTable: relation "common_inventreecustomuserstatemodel" does not exist LINE 1: ...treecustomuserstatemodel"."reference_status" FROM "common_in... ^

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

File "/opt/inventree/env/lib/python3.9/site-packages/django/core/handlers/base.py", line 220, in _get_response response = response.render()

File "/opt/inventree/env/lib/python3.9/site-packages/django/template/response.py", line 114, in render self.content = self.rendered_content

File "/opt/inventree/env/lib/python3.9/site-packages/django/template/response.py", line 92, in rendered_content return template.render(context, self._request)

File "/opt/inventree/env/lib/python3.9/site-packages/django/template/backends/django.py", line 61, in render return self.template.render(context)

File "/opt/inventree/env/lib/python3.9/site-packages/django/template/base.py", line 173, in render with context.bind_template(self):

File "/usr/lib/python3.9/contextlib.py", line 117, in enter return next(self.gen)

File "/opt/inventree/env/lib/python3.9/site-packages/django/template/context.py", line 254, in bind_template updates.update(processor(self.request))

File "/opt/inventree/src/backend/InvenTree/InvenTree/context.py", line 56, in status_codes cls.name: cls.template_context() for cls in get_custom_classes(get_custom)

File "/opt/inventree/src/backend/InvenTree/generic/states/custom.py", line 61, in get_custom_classes for item in list(InvenTreeCustomUserStateModel.objects.all()):

File "/opt/inventree/env/lib/python3.9/site-packages/django/db/models/query.py", line 380, in len self._fetch_all()

File "/opt/inventree/env/lib/python3.9/site-packages/django/db/models/query.py", line 1881, in _fetch_all self._result_cache = list(self._iterable_class(self))

File "/opt/inventree/env/lib/python3.9/site-packages/django/db/models/query.py", line 91, in iter results = compiler.execute_sql(

File "/opt/inventree/env/lib/python3.9/site-packages/django/db/models/sql/compiler.py", line 1562, in execute_sql cursor.execute(sql, params)

File "/opt/inventree/env/lib/python3.9/site-packages/django/db/backends/utils.py", line 67, in execute return self._execute_with_wrappers(

File "/opt/inventree/env/lib/python3.9/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers return executor(sql, params, many, context)

File "/opt/inventree/env/lib/python3.9/site-packages/django/db/backends/utils.py", line 89, in _execute return self.cursor.execute(sql, params)

File "/opt/inventree/env/lib/python3.9/site-packages/django/db/utils.py", line 91, in exit raise dj_exc_value.with_traceback(traceback) from exc_value

File "/opt/inventree/env/lib/python3.9/site-packages/django/db/backends/utils.py", line 89, in _execute return self.cursor.execute(sql, params)

django.db.utils.ProgrammingError: relation "common_inventreecustomuserstatemodel" does not exist LINE 1: ...treecustomuserstatemodel"."reference_status" FROM "common_in... ^**

Steps to Reproduce

Migrate from SQLITE3 to PGSQL then apt update && apt upgrade

Expected behaviour

I want to upgrade my instance for security patch and application patch

Deployment Method

  • [ ] Docker
  • [ ] Package
  • [x] Bare metal
  • [ ] Other - added info in Steps to Reproduce

Version Information

When I click on "System Information" or "About Inventree", nothing is working

Please verify if you can reproduce this bug on the demo site.

  • [ ] I can reproduce this bug on the demo site.

Relevant log output


IT-META avatar Mar 04 '25 20:03 IT-META

You need to run invoke update on your new instance before transferring any data - as per the documentation

SchrodingersGat avatar Mar 04 '25 22:03 SchrodingersGat

Hello,

I test this migration because i thought that the problem was the database model.

I test an update of my server and inventree. After the commande inventree run cli migrate, I have lost many informations on my database. The error log say:

**Info : no such table: common_inventreecustomuserstatemodel

Traceback (most recent call last):

File "/opt/inventree/env/lib/python3.9/site-packages/django/db/backends/utils.py", line 89, in _execute return self.cursor.execute(sql, params)

File "/opt/inventree/env/lib/python3.9/site-packages/django/db/backends/sqlite3/base.py", line 328, in execute return super().execute(query, params)

sqlite3.OperationalError: no such table: common_inventreecustomuserstatemodel**

Can anyone help me to find the problem ?

IT-META avatar Mar 05 '25 10:03 IT-META

This does not read like an issue with InvenTree but the instances administration. Can we close this?

matmair avatar Apr 17 '25 06:04 matmair

This issue seems stale. Please react to show this is still important.

github-actions[bot] avatar Jun 16 '25 11:06 github-actions[bot]