Problem/Motivation
When installing the website from existing config using drush,
the process breaks when module's install hook tries to create paragraph type icon and save new file entities:
[error] Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '873d0eed-987e-4b9b-8a3a-651edf3c1b6f' for key 'file_field__uuid__value': INSERT INTO "file_managed" ("uuid", "langcode", "uid", "filename", "uri", "filemime", "filesize", "status", "created", "changed") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9); Array
(
[:db_insert_placeholder_0] => 873d0eed-987e-4b9b-8a3a-651edf3c1b6f
[:db_insert_placeholder_1] => en
[:db_insert_placeholder_2] =>
[:db_insert_placeholder_3] => p_001.svg
[:db_insert_placeholder_4] => public://paragraphs_type_icon/p_001.svg
[:db_insert_placeholder_5] => image/svg+xml
[:db_insert_placeholder_6] => 538
[:db_insert_placeholder_7] => 1
[:db_insert_placeholder_8] => 1634573832
[:db_insert_placeholder_9] => 1634573832
)
in Drupal\Core\Database\Driver\mysql\ExceptionHandler->handleExecutionException() (line 50 of /var/www/html/docroot/core/lib/Drupal/Core/Database/Driver/mysql/ExceptionHandler.php).
In SqlContentEntityStorage.php line 810:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '873d0eed-987e-4b9b-8a3a-651edf3c1b6f' for key 'file_field__uuid__value': INSERT INTO "file_managed" ("uuid", "langcode", "uid", "filena
me", "uri", "filemime", "filesize", "status", "created", "changed") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4,
:db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9); Array
(
[:db_insert_placeholder_0] => 873d0eed-987e-4b9b-8a3a-651edf3c1b6f
[:db_insert_placeholder_1] => en
[:db_insert_placeholder_2] =>
[:db_insert_placeholder_3] => p_001.svg
[:db_insert_placeholder_4] => public://paragraphs_type_icon/p_001.svg
[:db_insert_placeholder_5] => image/svg+xml
[:db_insert_placeholder_6] => 538
[:db_insert_placeholder_7] => 1
[:db_insert_placeholder_8] => 1634573832
[:db_insert_placeholder_9] => 1634573832
)
In ExceptionHandler.php line 50:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '873d0eed-987e-4b9b-8a3a-651edf3c1b6f' for key 'file_field__uuid__value': INSERT INTO "file_managed" ("uuid", "langcode", "uid", "filena
me", "uri", "filemime", "filesize", "status", "created", "changed") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4,
:db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9); Array
(
[:db_insert_placeholder_0] => 873d0eed-987e-4b9b-8a3a-651edf3c1b6f
[:db_insert_placeholder_1] => en
[:db_insert_placeholder_2] =>
[:db_insert_placeholder_3] => p_001.svg
[:db_insert_placeholder_4] => public://paragraphs_type_icon/p_001.svg
[:db_insert_placeholder_5] => image/svg+xml
[:db_insert_placeholder_6] => 538
[:db_insert_placeholder_7] => 1
[:db_insert_placeholder_8] => 1634573832
[:db_insert_placeholder_9] => 1634573832
)
In StatementWrapper.php line 116:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '873d0eed-987e-4b9b-8a3a-651edf3c1b6f' for key 'file_field__uuid__value'
Steps to reproduce
Try to install project from existing config, when config contains some paragraph types with icons ( the ones created by rocketship_paragraphs module )
Proposed resolution
Try to load existing file by UUID before creating new one
Remaining tasks
Propose patch
User interface changes
None
API changes
None
Data model changes