You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The migration adds a linkedResource to each document having an associated DocumentResourceLink.
It happened that the migration failed in an instance because the related Resource was not found;
here the log
Applying documents.0037_delete_documentresourcelink...Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/django/db/backends/base/base.py", line 313, in _commit
return self.connection.commit()
psycopg2.errors.ForeignKeyViolation: insert or update on table "base_linkedresource" violates foreign key constraint "base_linkedresource_target_id_90785fa2_fk_base_resourcebase_id"
DETAIL: Key (target_id)=(181) is not present in table "base_resourcebase".
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/masdap/manage.py", line 31, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.10/dist-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.10/dist-packages/django/core/management/__init__.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.10/dist-packages/django/core/management/base.py", line 412, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.10/dist-packages/django/core/management/base.py", line 458, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.10/dist-packages/django/core/management/base.py", line 106, in wrapper
res = handle_func(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/django/core/management/commands/migrate.py", line 356, in handle
post_migrate_state = executor.migrate(
File "/usr/local/lib/python3.10/dist-packages/django/db/migrations/executor.py", line 135, in migrate
state = self._migrate_all_forwards(
File "/usr/local/lib/python3.10/dist-packages/django/db/migrations/executor.py", line 167, in _migrate_all_forwards
state = self.apply_migration(
File "/usr/local/lib/python3.10/dist-packages/django/db/migrations/executor.py", line 249, in apply_migration
with self.connection.schema_editor(
File "/usr/local/lib/python3.10/dist-packages/django/db/backends/base/schema.py", line 168, in __exit__
self.atomic.__exit__(exc_type, exc_value, traceback)
File "/usr/local/lib/python3.10/dist-packages/django/db/transaction.py", line 263, in __exit__
connection.commit()
File "/usr/local/lib/python3.10/dist-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/django/db/backends/base/base.py", line 337, in commit
self._commit()
File "/usr/local/lib/python3.10/dist-packages/django/db/backends/base/base.py", line 312, in _commit
with debug_transaction(self, "COMMIT"), self.wrap_database_errors:
File "/usr/local/lib/python3.10/dist-packages/django/db/utils.py", line 91, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/usr/local/lib/python3.10/dist-packages/django/db/backends/base/base.py", line 313, in _commit
return self.connection.commit()
django.db.utils.IntegrityError: insert or update on table "base_linkedresource" violates foreign key constraint "base_linkedresource_target_id_90785fa2_fk_base_resourcebase_id"
DETAIL: Key (target_id)=(181) is not present in table "base_resourcebase".
This may probably be caused by the linked layers to have been removed, and the link was not removed accordingly (was there a signal?). The DB did not have a FK on the resource, because the linked object could be anything -- on the DB where the error happened the linked resources were layers:
DB content details
select*from documents_documentresourcelink link
where not exists (select*from base_resourcebase br wherelink.object_id=br.id )
The migration adds a linkedResource to each document having an associated DocumentResourceLink.
It happened that the migration failed in an instance because the related Resource was not found;
here the log
This may probably be caused by the linked layers to have been removed, and the link was not removed accordingly (was there a signal?). The DB did not have a FK on the resource, because the linked object could be anything -- on the DB where the error happened the linked resources were layers:
DB content details
results:
The 3 resources have type 41:
The migration should exclude links that have no existing target.
Found on GeoNode 4.3.1
The text was updated successfully, but these errors were encountered: