1

I've create 20+ websites in Craft and each time I've always started with the use of another site's database. (time saving to not have to create all fields, sections and more)

On my latest site's database I see I have content from a very old website, build 2016.

What is the best way to delete old content from the database in a safe way?

craft_elements = 52mb craft_content = 34mb craft_element_sites = 34mb

3 Answers 3

1

"Personally I'd just use the 'select all' checkbox at the top of entries and delete them all at once."

That's what I've been doing - deleting all entries in the system. I've always thought that by deleting entries in the system it would clean the database.

But when looking in the database there is so much information that is still saved even though everything is deleted in the system.

Now I have a database that is over 300mb, with old content in Matrix columns, craft_elements and more.

UPDATE:

This is what I've done so far:

  1. In craft_elements I deleted all rows with type LIKE "Entry".
  2. Emptied all my matrix tables.

Because I cleaned all entries from the craft_elements I also removed the single section entries. By saving those sections again the entries where created.

The database have gone from 318mb to 16mb. The system seems to be working great now and I hope it will be in the future :)

1

Try manually forcing garbage collection after you've trashed all your entries in the CP. Using the cli, run ./craft gc

0

I'd avoid doing anything in the database directly. Personally I'd just use the 'select all' checkbox at the top of entries and delete them all at once.

You could also consider starting with a blank database and trying to apply a project config file to replicate the structure without the content. I haven't tried that yet though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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