1

During design/dev I created a bunch of matrix fields that I have since decided not to use. I have deleted the fields, however, I notice that the matrix tables are still in the database. Is it safe to delete these manually, or is there some other cleanup that needs to happen as well (i.e. references within another table, etc.)?

Update: The problem is caused when changing the fieldtype from a matrix field to another field type, rather than deleting the field altogether, and creating a new one. Even if the field is subsequently deleted, the matrix tables will still remain, which results in orphaned data in the DB.

| improve this question | | | | |
2

That shouldn't be the case... Those tables should have been deleted automatically when you deleted the fields.

Did you actually delete the fields themselves? Or did you simply remove them from your section's field layout? Make sure the actual fields were deleted within Settings > Fields


If you're positive those fields have been properly deleted...

Try updating to the latest version of Craft (v2.2.2587), which was released today. It includes this bug fix:

Retroactively fixed a bug where some Matrix block rows would get left behind in the database when an element was deleted that had a Matrix field.

If that doesn't resolve the problem for you, I'd recommend submitting a bug report to Pixel & Tonic. Submit the message via your Dashboard, so you can include a copy of your database and log files.

| improve this answer | | | | |
  • I double checked. The fields are definitely deleted. And I just updated a few minutes ago. The tables are still there. In fact, I have 6 matrix tables "craft_matrixcontent_field_handle" and only 1 matrix field. – Douglas McDonald Sep 25 '14 at 2:54
  • I tried creating a new matrix field and then deleting it. The corresponding table was properly created and deleted in the database. Must have been an old bug. Not too worried about it. You think its safe to delete those tables though? – Douglas McDonald Sep 25 '14 at 2:59
  • Probably safe... Have all of the corresponding rows in craft_elements been removed? Each matrix row contains an elementId which is a foreign key to the id column of the craft_elements table. You'll notice that every matching element is a MatrixBlock type. Make sure that any related MatrixBlock element rows are removed first, and those will cascade down to delete their respective matrix rows. Once those are all gone, go ahead and kill the tables. – Lindsey D Sep 25 '14 at 5:25
  • Oh, and not that it needs to be said, but... Back up your database before attempting anything like this! – Lindsey D Sep 25 '14 at 5:26
  • Thank you. So it looks like only one of the tables has any content in it. And I can see the entries in craft_entries. So I'll delete those first. I then see that I need to delete items from craft_matrixblocks, and craft_matrixblocktypes, then finally the craft_matrixcontent_fieldhandle tables. That sound about right? – Douglas McDonald Sep 25 '14 at 5:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.