Answers.Body: <p>As John mentioned, restoring a database backup is your best bet.</p>
  
  <p>If you don’t have a recent backup, you may still be able to get your Matrix content back, thanks to semi-bug where Craft doesn’t actually delete Matrix block content, when a Matrix field is converted to something else.</p>
  
  <p>Here’s what you can try:</p>
  
  <ol>
  <li><p><a href="https://docs.craftcms.com/v3/project-config.html#enabling-the-project-config-file" rel="nofollow noreferrer">Enable the Project Config file</a> for your site, if you don’t already have it enabled.</p></li>
  <li><p>Figure out what your field’s <code>uid</code> is by looking up its row in your database’s <code>fields</code> table.</p></li>
  <li><p>Find the most recent project config backup in <code>storage/config-backups/</code> where your field was still a Matrix field. The most recent backup will be called <code>project.yaml</code>, the second most recent will be called <code>project.yaml.1</code>, and so on. For each file, search for <code>&lt;field-uid&gt;:</code> (replace <code>&lt;field-uid&gt;</code> with the UID from step 2). If the nested <code>type</code> property is set to <code>craft\fields\Matrix</code>, you’ve found the right file. It will look something like this:</p></li>
  </ol>
  
  <pre><code>8823155c-e84a-4a38-af30-2cb88b705e7b:
    name: Body
    handle: body
    instructions: ''
    searchable: true
    translationMethod: none
    translationKeyFormat: null
    type: craft\fields\Matrix
    settings:
      maxBlocks: '3'
      localizeBlocks: false
      contentTable: '{{%matrixcontent_testimonials}}'
    fieldGroup: d58a1faa-0bf6-46b2-b880-b0c14bebca75
    contentColumnType: string
  </code></pre>
  
  <ol start="4">
  <li><p>Find the same field definition in your current <code>config/project.yaml</code> file, and replace it with the field definition from the backup you found in step 3.</p></li>
  <li><p>As a sanity check, you may want to compare the config backup from step 3 with the subsequent backup (so if you found your matrix field in <code>project.yaml.10</code>, compare it with <code>project.yaml.9</code>), using a diff tool like FileMerge (comes with macOS) or <a href="https://www.kaleidoscopeapp.com" rel="nofollow noreferrer">Kaleidoscope</a>. If there are any other significant changes that happened at the same time, you may want to revert those changes as well in <code>config/project.yaml</code>.</p></li>
  <li><p>Now access your Control Panel and click the button to sync your new <code>project.yaml</code> changes. When that’s done, if all goes well, your field should be a Matrix field again, and your content will be restored. </p></li>
  </ol>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-05T11:02:06.773Z
Answers.LastActivityDate: 2019-11-05T11:02:06.773Z
Answers.UserDisplayName: Brandon Kelly
Answers.Body: <p><code>'allowAdminChanges' =&gt; false</code> on your production server is also a tip I can give you.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-05T12:35:49.880Z
Answers.LastActivityDate: 2019-11-05T12:35:49.880Z
Answers.UserDisplayName: Michael Thomas
Answers.Body: <p>Restore your database from a recent backup is your only real option tbh.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-05T10:44:08.530Z
Answers.LastActivityDate: 2019-11-05T10:44:08.530Z
Answers.UserDisplayName: John
Body: <p>We accidentally deleted all our body text on all our pages, how do I redo my website to a older version. (24 hours ago)
  We changed matrix to assets and after that every body text disappeared. </p>
  
Tags: <assets><matrix>
Title: How can I restore Matrix content after accidentally changing its field type?
ThreadText: # How can I restore Matrix content after accidentally changing its field type?
  
  (Asked by: username_0 on 2019-11-05)
  
  We accidentally deleted all our body text on all our pages, how do I redo my website to a older version. (24 hours ago)
  We changed matrix to assets and after that every body text disappeared.
  
  **Tags:** assets, matrix
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2019-11-05. Score: 2
  
  As username_3 mentioned, restoring a database backup is your best bet.
  
  If you don’t have a recent backup, you may still be able to get your Matrix content back, thanks to semi-bug where Craft doesn’t actually delete Matrix block content, when a Matrix field is converted to something else.
  
  Here’s what you can try:
  
  1. [Enable the Project Config file](https://docs.craftcms.com/v3/project-config.html#enabling-the-project-config-file) for your site, if you don’t already have it enabled.
  2. Figure out what your field’s `uid` is by looking up its row in your database’s `fields` table.
  3. Find the most recent project config backup in `storage/config-backups/` where your field was still a Matrix field. The most recent backup will be called `project.yaml`, the second most recent will be called `project.yaml.1`, and so on. For each file, search for `<field-uid>:` (replace `<field-uid>` with the UID from step 2). If the nested `type` property is set to `craft\fields\Matrix`, you’ve found the right file. It will look something like this:
  
  ```
  8823155c-e84a-4a38-af30-2cb88b705e7b:
    name: Body
    handle: body
    instructions: ''
    searchable: true
    translationMethod: none
    translationKeyFormat: null
    type: craft\fields\Matrix
    settings:
      maxBlocks: '3'
      localizeBlocks: false
      contentTable: '{{%matrixcontent_testimonials}}'
    fieldGroup: d58a1faa-0bf6-46b2-b880-b0c14bebca75
    contentColumnType: string
  
  ```
  
  4. Find the same field definition in your current `config/project.yaml` file, and replace it with the field definition from the backup you found in step 3.
  5. As a sanity check, you may want to compare the config backup from step 3 with the subsequent backup (so if you found your matrix field in `project.yaml.10`, compare it with `project.yaml.9`), using a diff tool like FileMerge (comes with macOS) or [Kaleidoscope](https://www.kaleidoscopeapp.com). If there are any other significant changes that happened at the same time, you may want to revert those changes as well in `config/project.yaml`.
  6. Now access your Control Panel and click the button to sync your new `project.yaml` changes. When that’s done, if all goes well, your field should be a Matrix field again, and your content will be restored.
  
  
  ---
  
  ### Answer by username_2 on 2019-11-05. Score: 1
  
  `'allowAdminChanges' => false` on your production server is also a tip I can give you.
  
  
  ---
  
  ### Answer by username_3 on 2019-11-05. Score: 1
  
  Restore your database from a recent backup is your only real option tbh.
  
  
  ---
  
  