Answers.Body: <p><a href="https://civicrm.stackexchange.com/questions/18739/problem-fixing-missing-indexes-after-upgrade-to-4-7/21102#21102">Here</a> is the possible solution for this. Try running the sql queries through shell or phpmyadmin and than re-run the update indices.</p>
  
  <p>Looking at the db error i can see civirm_entity_financial_account have duplicate rows. Please get rid of one row or all with entity_id = 0 as it doesn't make sense and then re-run update indices.</p>
  
  <pre><code>Delete civicrm_entity_financial_account where entity_id = 0 and entity_table = 'civicrm_financial_type';
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-21T18:32:35.177Z
Answers.Text: Okay. What error are you getting when you run update indices?
Answers.UserDisplayName: Pradeep Nayak
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-21T18:35:25.407Z
Answers.Text: Updated my answer.
Answers.UserDisplayName: Pradeep Nayak
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-23T22:16:59.573Z
Answers.Text: This is what happens: 
  
  Error
  Static analysis:
  
  1 errors were found during analysis.
  
  Unexpected token. (near "civicrm_entity_financial_account" at position 7)
  SQL query:
  
  delete civicrm_entity_financial_account where entity_id = 0 and entity_table = 'civicrm_financial_type'
  
  MySQL said: Documentation
  
  #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'where entity_id = 0 and entity_table = 'civicrm_financial_type'' at line 1
Answers.UserDisplayName: David Christie
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-23T22:18:31.987Z
Answers.Text: I didn't re-run Update Indices yet
Answers.UserDisplayName: David Christie
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-27T15:00:25.367Z
Answers.Text: Deleted the unnecessary duplicate using SQL and the update ran through successfully. It took a bit of guts to push the delete button, but afterwards, it felt good!  ;-)
  
  Thanks for the info!
Answers.UserDisplayName: David Christie
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-27T15:03:17.963Z
Answers.Text: My pleasure... Cheerz
Answers.UserDisplayName: Pradeep Nayak
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-21T17:58:16.760Z
Answers.LastActivityDate: 2018-01-21T18:35:12.643Z
Answers.LastEditDate: 2018-01-21T18:35:12.643Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>I've messed around unsuccessfully to update indices by following various posts in StackExchange for similar errors. I have the impression that the Update Indices button simply does not work correctly.</p>
  
  <p>If I push it at the moment, I get: </p>
  
  <pre><code>DB Error: already exists
  Debug information:
  CREATE UNIQUE INDEX index_entity_id_entity_table_account_relationship ON civicrm_entity_financial_account (entity_id, entity_table, account_relationship) [nativecode=1062 ** Duplicate entry '0-civicrm_financial_type-12' for key 'index_entity_id_entity_table_account_relationship']
  </code></pre>
  
  <p>Does anyone have a good way of removing all indices and recreating them?</p>
  
  <p>I just upgraded from 4.7.25 to 4.7.29 (and am on the latest Wordpress version) if that is relevant.</p>
  
  <p>Tried <a href="https://civicrm.stackexchange.com/questions/21552/civicrm-update-4-7-27-operation-failed-update-indices-errno-150">CiviCRM Update 4.7.27 Operation failed: Update Indices Errno: 150</a> but it didn't work either <code>(complained about ALTER table civicrm_option_value DROP INDEX index_option_group_id_name with #1091 - Can't DROP 'index_option_group_id_name'; check that column/key exists)</code></p>
  
  <p>Thanks, David</p>
  
Tags: <indices>
Title: CiviCRM 4.7.29 Update Indices fails
ThreadText: # CiviCRM 4.7.29 Update Indices fails
  
  (Asked by: username_0 on 2018-01-21)
  
  I've messed around unsuccessfully to update indices by following various posts in StackExchange for similar errors. I have the impression that the Update Indices button simply does not work correctly.
  If I push it at the moment, I get: 
  DB Error: already exists
  Debug information:
  CREATE UNIQUE INDEX index_entity_id_entity_table_account_relationship ON civicrm_entity_financial_account (entity_id, entity_table, account_relationship) [nativecode=1062 ** Duplicate entry '0-civicrm_financial_type-12' for key 'index_entity_id_entity_table_account_relationship']
  
  Does anyone have a good way of removing all indices and recreating them?
  I just upgraded from 4.7.25 to 4.7.29 (and am on the latest Wordpress version) if that is relevant.
  Tried CiviCRM Update 4.7.27 Operation failed: Update Indices Errno: 150 but it didn't work either (complained about ALTER table civicrm_option_value DROP INDEX index_option_group_id_name with #1091 - Can't DROP 'index_option_group_id_name'; check that column/key exists)
  Thanks, David
  
  **Tags:** indices
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-01-21. Score: 0 | Accepted answer
  
  Here is the possible solution for this. Try running the sql queries through shell or phpmyadmin and than re-run the update indices.
  Looking at the db error i can see civirm_entity_financial_account have duplicate rows. Please get rid of one row or all with entity_id = 0 as it doesn't make sense and then re-run update indices.
  Delete civicrm_entity_financial_account where entity_id = 0 and entity_table = 'civicrm_financial_type';
  
  > **Comments:**
  > **username_1**: Okay. What error are you getting when you run update indices?  
  > **username_1**: Updated my answer.  
  > **username_0**: This is what happens:   Error Static analysis:  1 errors were found during analysis.  Unexpected token. (near "civicrm_entity_financial_account" at position 7) SQL query:  delete civicrm_entity_financial_account where entity_id = 0 and entity_table = 'civicrm_financial_type'  MySQL said: Documentation  #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'where entity_id = 0 and entity_table = 'civicrm_financial_type'' at line 1  
  > **username_0**: I didn't re-run Update Indices yet  
  > **username_0**: Deleted the unnecessary duplicate using SQL and the update ran through successfully. It took a bit of guts to push the delete button, but afterwards, it felt good!  ;-)  Thanks for the info!  
  > **username_1**: My pleasure... Cheerz  
  
  ---
  
  