Problem/Motivation
When trying to run tome:install via drush it always seems to try and create a new admin user rather than use the existing admin user
Steps to reproduce
Output from ddev drush -y tome:install
ddev drush -y tome:install
// You are about to DROP all tables in your local database and re-install Tome. Do you want to continue?: yes.
In Process.php line 266:
The command "/var/www/html/vendor/drush/drush/drush tome:import --yes --uri=https://8080-white-krill-1phmiee1.ws-us18.gitpod.io --root=/var/www/html/web" failed.
Exit Code: 1(General error)
Working directory:
Output:
================
[ERROR] Errors encountered when importing content:
[ERROR] Error when running "/var/www/html/vendor/drush/drush/drush tome:import-content
'user.1b3891f2-9fb7-4c4b-a2a4-e5479995b365,user.fb85df17-bbd5-4b75-890e-e010d6410ac0'":
[error] Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[23000]: Integrity constraint
violation: 1062 Duplicate entry '1' for key 'PRIMARY': INSERT INTO "users" ("uid", "uuid", "langcode") VALUES
(:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array
(
[:db_insert_placeholder_0] => 1
[:db_insert_placeholder_1] => fb85df17-bbd5-4b75-890e-e010d6410ac0
[:db_insert_placeholder_2] => en
)
in Drupal\Core\Database\Driver\mysql\ExceptionHandler->handleExecutionException() (line 50 of
/var/www/html/web/core/lib/Drupal/Core/Database/Driver/mysql/ExceptionHandler.php).
In SqlContentEntityStorage.php line 810:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1' for key 'PRIMARY': INSERT INTO
"users" ("uid", "uuid", "langcode") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1,
:db_insert_placeholder_2); Array
(
[:db_insert_placeholder_0] => 1
[:db_insert_placeholder_1] => fb85df17-bbd5-4b75-890e-e010d6410ac0
[:db_insert_placeholder_2] => en
)
In ExceptionHandler.php line 50:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1' for key 'PRIMARY': INSERT INTO
"users" ("uid", "uuid", "langcode") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1,
:db_insert_placeholder_2); Array
(
[:db_insert_placeholder_0] => 1
[:db_insert_placeholder_1] => fb85df17-bbd5-4b75-890e-e010d6410ac0
[:db_insert_placeholder_2] => en
)
In StatementWrapper.php line 116:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1' for key 'PRIMARY'
Error Output:
================
Failed to run drush -y tome:install: exit status 1
Testing using tome:import
drush si foundry -y
drush tome:import -y
[ERROR] Errors encountered when importing content:
[ERROR] Error when running "/var/www/html/vendor/bin/drush tome:import-content
'user.20ce9e92-a69b-4937-8c59-b3f16bc138b6,user.fb85df17-bbd5-4b75-890e-e010d6410ac0'":
[error] Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[23000]: Integrity constraint
violation: 1062 Duplicate entry '1' for key 'PRIMARY': INSERT INTO "users" ("uid", "uuid", "langcode") VALUES
(:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array
(
[:db_insert_placeholder_0] => 1
[:db_insert_placeholder_1] => fb85df17-bbd5-4b75-890e-e010d6410ac0
[:db_insert_placeholder_2] => en
)
in Drupal\Core\Database\Driver\mysql\ExceptionHandler->handleExecutionException() (line 50 of
/var/www/html/web/core/lib/Drupal/Core/Database/Driver/mysql/ExceptionHandler.php).
In SqlContentEntityStorage.php line 810:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1' for key 'PRIMARY': INSERT INTO
"users" ("uid", "uuid", "langcode") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1,
:db_insert_placeholder_2); Array
(
[:db_insert_placeholder_0] => 1
[:db_insert_placeholder_1] => fb85df17-bbd5-4b75-890e-e010d6410ac0
[:db_insert_placeholder_2] => en
)
In ExceptionHandler.php line 50:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1' for key 'PRIMARY': INSERT INTO
"users" ("uid", "uuid", "langcode") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1,
:db_insert_placeholder_2); Array
(
[:db_insert_placeholder_0] => 1
[:db_insert_placeholder_1] => fb85df17-bbd5-4b75-890e-e010d6410ac0
[:db_insert_placeholder_2] => en
)
In StatementWrapper.php line 116:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1' for key 'PRIMARY'
Failed to run drush tome:import -y: exit status 1
Comments
Comment #2
samuel.mortensonI noticed your export (https://github.com/Realityloop/statertkit-drupal-foundry-tome-druxt/tree...) has no user 0, which is odd. I'm wondering if this could be related to the issue you're having - could you try restoring user 0 and re-running the install? One way to do this would be to copy/edit a user 0 from another Tome site (ex: https://github.com/mortenson/mortenson.github.io/blob/develop/content/us...).
Comment #3
realityloop commentedI added the uid 0 user file as you referenced in your repo, and updated meta/index.json to reference the user.
https://github.com/Realityloop/statertkit-drupal-foundry-tome-druxt/blob...
https://github.com/Realityloop/statertkit-drupal-foundry-tome-druxt/blob...
Still having the same result unfortunately
Comment #4
trafo commentedI have similar problem. I think that problem is how
user:1(admin) is handled. This admin user is created duringdrush site-install, but has different UUID than user:1 that is exported via tome in JSON.Drupal\tome_sync\Importer::importContent()tries to load entities by UUID and since existing user:1 and the one being imported has different UUID it tries to create another user:1, which results in error.Since I'm running site-install on my own, for now my fix is to update user:1 and user:0 UUID to the ones that are exported and run
tome:import.Comment #5
samuel.mortenson@trafo That implies that Tome is enabled somewhere during the install process. If so, that will cause problems. The tome:install command installs it after site-install runs to avoid these issues.
Comment #6
samuel.mortensonIf it's possible to disable Tome export during a site install that seems OK, I'm just not sure how to check for that. It's also possibly a BC break but I don't think it's a huge deal.
Comment #7
samuel.mortensonSomething like this?
Comment #8
samuel.mortensonFound a better core API - will probably commit today.
Comment #10
samuel.mortensonClosing as fixed for this specific profile-install case - I'm sure there are other ways to break user imports, but I think it's better to throw errors and investigate what's going on then add (more) special handling of User UIDs. Thanks for bringing this up all!