Bug #10831

agent_m2m_event migration breaks on upgrade from 1.5.1

Added by Justin Simpson almost 5 years ago. Updated almost 5 years ago.

Status:QA/ReviewStart date:01/27/2017
Priority:HighDue date:
Assignee:-% Done:

0%

Category:-
Target version:Release 1.6
Google Code Legacy ID: Pull Request:https://github.com/artefactual/archivematica/pull/561
Sponsored:No Requires documentation:

Description

during upgrade, when running:

python manage.py migrate

on an existing 1.5.1 installation, the output shows an error in migration 0026:

Running migrations:
Rendering model states... DONE
Applying administration.0005_archivesspace_inherit_note_default... OK
Applying administration.0006_use_statement_optional... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying main.0018_archivesspace_sip_arrange... OK
Applying main.0020_index_after_processing_decision... OK
Applying main.0021_checksum_algorithms... OK
Applying main.0022_email_report_args... OK
Applying main.0023_blob_fields... OK
Applying main.0024_agenttype... OK
Applying main.0025_copyrightstatus_controlled_vocab... OK
Applying main.0026_agent_m2m_event...Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 346, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 394, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 445, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/migrate.py", line 222, in handle
executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 110, in migrate
self.apply_migration(states[migration], migration, fake=fake, fake_initial=fake_initial)
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 148, in apply_migration
state = migration.apply(state, schema_editor)
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/migration.py", line 112, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/operations/special.py", line 183, in database_forwards
self.code(from_state.apps, schema_editor)
File "/opt/archivematica/archivematica/src/dashboard/src/main/migrations/0026_agent_m2m_event.py", line 28, in data_migration
user_agent = Agent.objects.get(userprofile__user_id=e.linking_agent)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py", line 127, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 338, in get
(self.model._meta.object_name, num)
fake.MultipleObjectsReturned: get() returned more than one Agent -- it returned 2!

The Events table had 2740 rows in it, 43 of which had a null in the linkingAgentIdentifier column. I am assuming it is the nulls that were the problem.

I reran the migration with those 43 rows deleted, and it worked fine.

History

#1 Updated by Justin Simpson almost 5 years ago

  • Status changed from New to Code Review
  • Pull Request set to https://github.com/artefactual/archivematica/pull/561

A fix available in PR561, tested with data from amtest.artefactual.net, this PR is able to upgrade that vm without errors.

#2 Updated by Justin Simpson almost 5 years ago

  • Status changed from Code Review to QA/Review
  • Assignee deleted (Justin Simpson)

Pull Request has been merged into qa/1.6.x and qa/1.x and is available in v1.6.0-rc2 tag.

Testing requires upgrading an existing 1.5.1 server with packages that have been processed.

Also available in: Atom PDF