Issue with MassiveStore and relation
It looks like we have an issue while restoring the schema if some etype are both in subject and object
My schema:
class related_subject(RelationDefinition):
"""
This relation is used to represent relations between an author and an other entity
such as this other entity is the subject of a contribution or a manifestation about
this author.
see: https://forge.bnf.fr/issues/43221
"""
__permissions__ = make_rel_update_perms(du_role="both")
subject = ("Person", "ElementaryPerson", "Org", "Work", "Performance", "Periodic")
object = ("Person", "ElementaryPerson", "Org", "Work", "Rameau", "Geo")
cardinality = "**"
Exception:
2022-01-20 16:55:20,196 ERROR postprocess-related-subject failed
Traceback (most recent call last):
File "/home/fferry/src/projets/projetBNF/databnf/cubicweb_databnf/dataimport/__init__.py", line 402, in batch_environment
yield
File "/home/fferry/src/projets/projetBNF/databnf/cubicweb_databnf/dataimport/__init__.py", line 1286, in run
postprocess_related_subject(cnx)
File "/home/fferry/src/projets/projetBNF/databnf/cubicweb_databnf/__init__.py", line 161, in wrapped
res = func(cnx, *args, **kwargs)
File "/home/fferry/src/projets/projetBNF/databnf/cubicweb_databnf/dataimport/postprocess.py", line 1479, in postprocess_related_subject
store.finish()
File "/home/fferry/src/projets/projetBNF/venv-py37/lib/python3.7/site-packages/cubicweb/dataimport/massive_store.py", line 215, in finish
self._finish()
File "/home/fferry/src/projets/projetBNF/venv-py37/lib/python3.7/site-packages/cubicweb/dataimport/massive_store.py", line 274, in _finish
self._dbh.restore_indexes_and_constraints()
File "/home/fferry/src/projets/projetBNF/venv-py37/lib/python3.7/site-packages/cubicweb/dataimport/massive_store.py", line 441, in restore_indexes_and_constraints
self.sql(query)
File "/home/fferry/src/projets/projetBNF/venv-py37/lib/python3.7/site-packages/cubicweb/server/session.py", line 157, in check_open
return func(cnx, *args, **kwargs)
File "/home/fferry/src/projets/projetBNF/venv-py37/lib/python3.7/site-packages/cubicweb/server/session.py", line 812, in system_sql
rql_query_tracing_token=rql_query_tracing_token,
File "/home/fferry/src/projets/projetBNF/venv-py37/lib/python3.7/site-packages/cubicweb/server/sources/native.py", line 812, in doexec
cursor.execute(str(query), args)
psycopg2.errors.DuplicateObject: when doing the query 'ALTER TABLE related_subject_relation ADD CONSTRAINT related_subject_relation_eid_to_fkey FOREIGN KEY (eid_to) REFERENCES entities(eid)' with the args 'None' got the error 'ERREUR: la contrainte « related_subject_relation_eid_to_fkey » de la relation « related_subject_relation » existe déjà'