Body: <p>Once upon a time, if you thought your database schema was no longer matching what CiviCRM expected, it was recommended that you create a new civicrm install with your current version, dump it and your production site without data, and compare.</p>
  <p>Of course, that's a bit of a bear, especially because sometimes the order of the fields might be different.</p>
  <p>Now that we have a <a href="https://civicrm.org/blog/colemanw/what-xml-where-did-dao-go" rel="nofollow noreferrer">new way of defining the schema</a>, what's the best way of reviewing my database for e.g. missing db upgrade steps? And fixing it! Anybody got some useful code and/or processes?</p>
  <p>FWIW, this civicrm install was created more than 10 years ago.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-07-11T13:42:53.237Z
Comments.Text: I'd say dump is still the best way.
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-07-11T19:30:25.030Z
Comments.Text: When is ChatGPT going to solve this problem? What's the point of AI if it doesn't solve my problems?
Comments.UserDisplayName: Alan Dixon
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-07-11T19:40:01.890Z
Comments.Text: Hehe. I don't think solving _our_ problems was ever the purpose. But I'd be curious what it says about this problem.
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-07-12T07:26:02.143Z
Comments.Text: I had this exact problem with an 11 year old install, missing FK constraints, and dumping it had some benefits of getting rid of junk that an "AI driven" rebuild would have missed.
Comments.UserDisplayName: Andy Clark
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-07-12T12:54:16.590Z
Comments.Text: Alternatively to dump-without-data-and-compare, I could dump the new install without data, and dump production without the schema (--no-create-info) and then load up the aspirational schema and then the production data, fingers crossed.
Comments.UserDisplayName: Alan Dixon
Tags: <database>
Title: How can I fix my civicrm database table schema?
ThreadText: # How can I fix my civicrm database table schema?
  
  (Asked by: username_0 on 2024-07-11)
  
  Once upon a time, if you thought your database schema was no longer matching what CiviCRM expected, it was recommended that you create a new civicrm install with your current version, dump it and your production site without data, and compare.
  
  Of course, that's a bit of a bear, especially because sometimes the order of the fields might be different.
  
  Now that we have a [new way of defining the schema](https://civicrm.org/blog/colemanw/what-xml-where-did-dao-go), what's the best way of reviewing my database for e.g. missing db upgrade steps? And fixing it! Anybody got some useful code and/or processes?
  
  FWIW, this civicrm install was created more than 10 years ago.
  
  **Tags:** database
  
  > **Comments:**
  > **username_1**: I'd say dump is still the best way.  
  > **username_0**: When is ChatGPT going to solve this problem? What's the point of AI if it doesn't solve my problems?  
  > **username_1**: Hehe. I don't think solving _our_ problems was ever the purpose. But I'd be curious what it says about this problem.  
  > **username_2**: I had this exact problem with an 11 year old install, missing FK constraints, and dumping it had some benefits of getting rid of junk that an "AI driven" rebuild would have missed.  
  > **username_0**: Alternatively to dump-without-data-and-compare, I could dump the new install without data, and dump production without the schema (--no-create-info) and then load up the aspirational schema and then the production data, fingers crossed.  
  
  ---
  
  ## 0 answers
  
  