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
CommentFileSizeAuthor
#8 3246331-8.patch780 bytessamuel.mortenson
#7 3246331-7.patch576 bytessamuel.mortenson

Comments

realityloop created an issue. See original summary.

samuel.mortenson’s picture

I 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...).

realityloop’s picture

I 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

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-kumquat-bovid-jnnucajg.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.0ad60ecc-9ec4-4b1b-aab5-ff76ab06fe1f,user.fb85df17-bbd5-4b75-890e-e010d6410ac0,user.7405b79f-638c-46db-97                                             
           e8-3cb339655225'":                                                                                                                                          
              [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
trafo’s picture

I have similar problem. I think that problem is how user:1 (admin) is handled. This admin user is created during drush 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.

samuel.mortenson’s picture

@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.

samuel.mortenson’s picture

If 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.

samuel.mortenson’s picture

Status: Active » Needs review
StatusFileSize
new576 bytes

Something like this?

samuel.mortenson’s picture

StatusFileSize
new780 bytes

Found a better core API - will probably commit today.

  • samuel.mortenson authored 9c49395 on 8.x-1.x
    Issue #3246331 by samuel.mortenson, realityloop, trafo: tome:install...
samuel.mortenson’s picture

Status: Needs review » Fixed

Closing 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!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.