Answers.Body: <p>Solved this one by adding SET foreign_key_checks = 0; to the beginning of the SQL dump and SET foreign_key_checks = 1; at the end of the file. Not sure if it is the best solution but it certainly worked.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-08T20:18:00.563Z
Answers.Text: This is just kicking the can down the road.  You've got inconsistent data in your database (for whatever reason) that should be fixed.  Settings FK checks to 0 on import is just saying "ignore those problems".
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-09T08:57:03.353Z
Answers.Text: @bradbell yes I realise this. Can you suggest anyway of fixing the inconsistent data? What we need to check for and any preferred software to do it? Cheers.
Answers.UserDisplayName: Lettie
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-09T16:51:19.860Z
Answers.Text: For this particular error, it's complaining about data that's in the `elementId` column of the `craft_matrixcontent_newscontent` table that is missing in the `id` column of the `craft_elements` table.  So you'd want to write a SQL query that finds the missing data. https://stackoverflow.com/questions/3826929/sql-query-to-find-missing-rows-between-two-related-tables
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-13T08:59:15.683Z
Answers.Text: Cheers @bradbell will create something.
Answers.UserDisplayName: Lettie
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-08T16:00:40.267Z
Answers.LastActivityDate: 2016-06-08T16:00:40.267Z
Answers.UserDisplayName: Lettie
Body: <p>Since upgrading to craft 2.6.2785 when I delete a user it appears to remove the user from the <code>elements</code> and <code>elements_il8n</code> tables but does not delete the user from the <code>users</code> table.</p>
  
  <p>If you then search for the user in the CMS it does not find them however the user has not been removed from the database so if you try and set up a new user with the same email address it fails with "email has already been taken message".</p>
  
  <hr>
  
  <p>Update on this. I re-imported the database from dev to staging. In my dev deleting users works fine. When importing the database which is fairly large due to 20k+ users I get this error:</p>
  
  <pre><code>SQL Error (1452) Cannot add or update a child row:a foreign key constraint fails ('databaseName'.'#sql-1510_62265', CONSTRAINT 'craft_matrixcontent_newscontent_elementId_fk' FOREIGN KEY ('elementId') REFERENCES 'craft_elements' ('id') ON DELETE CASCADE)
  </code></pre>
  
  <p>Then when trying to delete a user it says it's deleted removes the elements from the element tables but does not remove the user from the <code>users</code> table.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-06-08T10:46:54.540Z
Comments.Text: Were any Entries authored by the deleted user?
Comments.UserDisplayName: Matt P
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-06-08T12:34:32.440Z
Comments.Text: No no entries. I think this maybe to do with a possible corrupt database or plugin now so will investigate further.
Comments.UserDisplayName: Lettie
Tags: <users><database><mysql><delete>
Title: Users not being deleted from the craft_users table?
ThreadText: # Users not being deleted from the craft_users table?
  
  (Asked by: username_0 on 2016-06-08)
  
  Since upgrading to craft 2.6.2785 when I delete a user it appears to remove the user from the `elements` and `elements_il8n` tables but does not delete the user from the `users` table.
  
  If you then search for the user in the CMS it does not find them however the user has not been removed from the database so if you try and set up a new user with the same email address it fails with "email has already been taken message".
  
  ---
  
  Update on this. I re-imported the database from dev to staging. In my dev deleting users works fine. When importing the database which is fairly large due to 20k+ users I get this error:
  
  ```
  SQL Error (1452) Cannot add or update a child row:a foreign key constraint fails ('databaseName'.'#sql-1510_62265', CONSTRAINT 'craft_matrixcontent_newscontent_elementId_fk' FOREIGN KEY ('elementId') REFERENCES 'craft_elements' ('id') ON DELETE CASCADE)
  
  ```
  
  Then when trying to delete a user it says it's deleted removes the elements from the element tables but does not remove the user from the `users` table.
  
  **Tags:** users, database, mysql, delete
  
  > **Comments:**
  > **username_1**: Were any Entries authored by the deleted user?  
  > **username_0**: No no entries. I think this maybe to do with a possible corrupt database or plugin now so will investigate further.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2016-06-08. Score: 1
  
  Solved this one by adding SET foreign\_key\_checks = 0; to the beginning of the SQL dump and SET foreign\_key\_checks = 1; at the end of the file. Not sure if it is the best solution but it certainly worked.
  
  > **Comments:**
  > **username_2**: This is just kicking the can down the road.  You've got inconsistent data in your database (for whatever reason) that should be fixed.  Settings FK checks to 0 on import is just saying "ignore those problems".  
  > **username_0**: @username_2 yes I realise this. Can you suggest anyway of fixing the inconsistent data? What we need to check for and any preferred software to do it? Cheers.  
  > **username_2**: For this particular error, it's complaining about data that's in the `elementId` column of the `craft_matrixcontent_newscontent` table that is missing in the `id` column of the `craft_elements` table.  So you'd want to write a SQL query that finds the missing data. https://stackoverflow.com/questions/3826929/sql-query-to-find-missing-rows-between-two-related-tables  
  > **username_0**: Cheers @username_2 will create something.  
  
  ---
  
  