InvenTree: Updating Inventree to 0.12.8. fails at datatbase migration
Deployment Method
- Installer
- Docker Development
- Docker Production
- Bare metal Development
- Bare metal Production
- Digital Ocean image
- Other (please provide a link
Steps to Reproduce
Describe the problem*
Hi, When trying to update Inventree to the latest version (0.12.8) I get an error in the database migration step (see log output section)
Steps to Reproduce
Followed instructions on this page
-
Stop server: sudo docker-compose down
-
Backup DB: sudo docker-compose run inventree-server invoke backup
-
Download new version: sudo docker-compose pull
Migtrate DB to new version: sudo docker-compose run inventree-server invoke update
This is whwere error happens
Relevant log output
Running InvenTree database migrations...
========================================
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
No changes detected
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
Operations to perform:
Apply all migrations: InvenTree, account, admin, auth, authtoken, build, common, company, contenttypes, django_q, error_report, exchange, flags, label, order, otp_static, otp_totp, part, plugin, report, sites, socialaccount, stock, taggit, user_sessions, users
Running migrations:
Applying InvenTree.0001_initial...Traceback (most recent call last):
File "/root/.local/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "django_migrations_pkey"
DETAIL: Key (id)=(431) already exists.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/inventree/InvenTree/manage.py", line 23, in <module>
execute_from_command_line(sys.argv)
File "/root/.local/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
utility.execute()
File "/root/.local/lib/python3.9/site-packages/django/core/management/__init__.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/root/.local/lib/python3.9/site-packages/django/core/management/base.py", line 354, in run_from_argv
self.execute(*args, **cmd_options)
File "/root/.local/lib/python3.9/site-packages/django/core/management/base.py", line 398, in execute
output = self.handle(*args, **options)
File "/root/.local/lib/python3.9/site-packages/django/core/management/base.py", line 89, in wrapped
res = handle_func(*args, **kwargs)
File "/root/.local/lib/python3.9/site-packages/django/core/management/commands/migrate.py", line 244, in handle
post_migrate_state = executor.migrate(
File "/root/.local/lib/python3.9/site-packages/django/db/migrations/executor.py", line 117, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "/root/.local/lib/python3.9/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "/root/.local/lib/python3.9/site-packages/django/db/migrations/executor.py", line 229, in apply_migration
self.record_migration(migration)
File "/root/.local/lib/python3.9/site-packages/django/db/migrations/executor.py", line 244, in record_migration
self.recorder.record_applied(migration.app_label, migration.name)
File "/root/.local/lib/python3.9/site-packages/django/db/migrations/recorder.py", line 87, in record_applied
self.migration_qs.create(app=app, name=name)
File "/root/.local/lib/python3.9/site-packages/django/db/models/query.py", line 453, in create
obj.save(force_insert=True, using=self.db)
File "/root/.local/lib/python3.9/site-packages/django/db/models/base.py", line 739, in save
self.save_base(using=using, force_insert=force_insert,
File "/root/.local/lib/python3.9/site-packages/django/db/models/base.py", line 776, in save_base
updated = self._save_table(
File "/root/.local/lib/python3.9/site-packages/django/db/models/base.py", line 881, in _save_table
results = self._do_insert(cls._base_manager, using, fields, returning_fields, raw)
File "/root/.local/lib/python3.9/site-packages/django/db/models/base.py", line 919, in _do_insert
return manager._insert(
File "/root/.local/lib/python3.9/site-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/root/.local/lib/python3.9/site-packages/django/db/models/query.py", line 1270, in _insert
return query.get_compiler(using=using).execute_sql(returning_fields)
File "/root/.local/lib/python3.9/site-packages/django/db/models/sql/compiler.py", line 1416, in execute_sql
cursor.execute(sql, params)
File "/root/.local/lib/python3.9/site-packages/django/db/backends/utils.py", line 66, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/root/.local/lib/python3.9/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/root/.local/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "/root/.local/lib/python3.9/site-packages/django/db/utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/root/.local/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
django.db.utils.IntegrityError: duplicate key value violates unique constraint "django_migrations_pkey"
DETAIL: Key (id)=(431) already exists.
ERROR: 1
About this issue
- Original URL
- State: open
- Created 8 months ago
- Comments: 33 (15 by maintainers)
Commits related to this issue
- Handle "showmigrations" command - If provided, do not load custom app ready code - Ref: https://github.com/inventree/InvenTree/issues/5804#issuecomment-1785562383 — committed to inventree/InvenTree by SchrodingersGat 7 months ago
- Handle "showmigrations" command (#6062) - If provided, do not load custom app ready code - Ref: https://github.com/inventree/InvenTree/issues/5804#issuecomment-1785562383 — committed to inventree/InvenTree by SchrodingersGat 7 months ago
No not really. I use only one db for all my services and that’s at the moment postgrsql 16.
I have created an issue for improving the docker deployment https://github.com/inventree/InvenTree/issues/6303
@SchrodingersGat Thanks for the advice. I tried to update to
0.10.0But unfortunatly got a similar error then before: