Mayan 4.0b1 - error in migrations

When things don't work as they should.
Post Reply
qra
Posts: 28
Joined: Fri Oct 25, 2019 9:08 pm

Mayan 4.0b1 - error in migrations

Post by qra »

Hi. When I try to install Mayan EDMS 4.0b1 on fresh Ubuntu 18.04, I get an error while migrating.

Code: Select all

...
  Applying documents.0059_auto_20200918_0616... OK
  Applying documents.0060_documentversion...Traceback (most recent call last):
  File "/opt/mayan-edms/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
psycopg2.errors.DuplicateTable: relation "documents_documentversion_timestamp_30bada95" already exists


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

Traceback (most recent call last):
  File "/opt/mayan-edms/bin/mayan-edms.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/opt/mayan-edms/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/opt/mayan-edms/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/opt/mayan-edms/lib/python3.6/site-packages/django/core/management/base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/opt/mayan-edms/lib/python3.6/site-packages/django/core/management/base.py", line 364, in execute
    output = self.handle(*args, **options)
  File "/opt/mayan-edms/lib/python3.6/site-packages/mayan/apps/common/management/commands/initialsetup.py", line 87, in handle
    signal_pre_initial_setup.send(sender=self)
  File "/opt/mayan-edms/lib/python3.6/site-packages/django/dispatch/dispatcher.py", line 175, in send
    for receiver in self._live_receivers(sender)
  File "/opt/mayan-edms/lib/python3.6/site-packages/django/dispatch/dispatcher.py", line 175, in <listcomp>
    for receiver in self._live_receivers(sender)
  File "/opt/mayan-edms/lib/python3.6/site-packages/mayan/apps/common/handlers.py", line 5, in handler_pre_initial_setup
    management.call_command(command_name='migrate', interactive=False)
  File "/opt/mayan-edms/lib/python3.6/site-packages/django/core/management/__init__.py", line 148, in call_command
    return command.execute(*args, **defaults)
  File "/opt/mayan-edms/lib/python3.6/site-packages/django/core/management/base.py", line 364, in execute
    output = self.handle(*args, **options)
  File "/opt/mayan-edms/lib/python3.6/site-packages/django/core/management/base.py", line 83, in wrapped
    res = handle_func(*args, **kwargs)
  File "/opt/mayan-edms/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 234, in handle
    fake_initial=fake_initial,
  File "/opt/mayan-edms/lib/python3.6/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 "/opt/mayan-edms/lib/python3.6/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 "/opt/mayan-edms/lib/python3.6/site-packages/django/db/migrations/executor.py", line 247, in apply_migration
    migration_recorded = True
  File "/opt/mayan-edms/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 110, in __exit__
    self.execute(sql)
  File "/opt/mayan-edms/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 137, in execute
    cursor.execute(sql, params)
  File "/opt/mayan-edms/lib/python3.6/site-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/opt/mayan-edms/lib/python3.6/site-packages/django/db/backends/utils.py", line 76, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/opt/mayan-edms/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/opt/mayan-edms/lib/python3.6/site-packages/django/db/utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/opt/mayan-edms/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: relation "documents_documentversion_timestamp_30bada95" already exists
User avatar
rosarior
Developer
Developer
Posts: 649
Joined: Tue Aug 21, 2018 3:28 am
Location: Puerto Rico
Contact:

Re: Mayan 4.0b1 - error in migrations

Post by rosarior »

Thanks for the report.

We found a bug in Django (https://code.djangoproject.com/ticket/23577) which cause existing indexes to not be updated when their underlying tables are renamed. We are auditing each migration and fine tuning as well as optimizing them.

In the case of this migration a fix was submitted and will be available the next beta image: https://gitlab.com/mayan-edms/mayan-edm ... b817883f63

The next beta will be available as soon as we finish auditing and optimizing the remaining migrations (about 5 from the OCR app).

Thanks for the report and for trying out the beta version!
Post Reply