M1 > M2 Database Cleanup Tool

I get pretty particular about things and thus it led me to stumble upon this nifty tool. Use it with caution and check the results, but it can help cleanup the M2 database after doing a migration. As usual, makes backups and make sure they work.

Cleans up database and images:

Magento 2 EAV Cleaner Console Command

Purpose of this project is to check for different flaws that can occur due to EAV and provide cleanup functions.

Dry run

Use --dry-run to check result without modifying data.


  • eav:config:restore-use-default-value Check if config admin value and storeview value are the same, so “use default” doesn’t work anymore. Delete the storeview values.
  • eav:attributes:restore-use-default-value Check if product attribute admin value and storeview value are the same, so “use default” doesn’t work anymore. Delete the storeview values.
  • eav:attributes:remove-unused Remove attributes with no values set in products and attributes that are not present in any attribute sets.
  • eav:media:remove-unused Remove unused product images.


Run bin/magento in the Magento 2 root and look for the eav: commands.


Installation with composer:

composer require hackathon/magento2-eavcleaner

Then the usual magento cache clear, upgrade etc…
rm -rf var/cache/* var/page_cache/* generated/code/* && bin/magento setup:upgrade && bin/magento setup:di:compile && bin/magento setup:static-content:deploy -f && bin/magento indexer:reindex && bin/magento cache:clean && bin/magento cache:flush


  • Nikita Zhavoronkova
  • Anastasiia Sukhorukova
  • Peter Jaap Blaakmeer

Special thanks to

  • Benno Lippert
  • Damian Luszczymak
  • Joke Puts
  • Ralf Siepker

I have used this and didn’t notice any ill effects. I did not use: eav:attributes:remove-unused as there were only a few unused attributes in my installation and it wasn’t worth risking them being tied to something necessary. It is unlikely, but removing 5 unused attributes for me wasn’t going to make a difference.

I think I removed around 800MB in images from my previous installation. It may remove the watermark folder. I copied the outputs so I can view the results in its entirety, if necessary. Simply append > output.txt to your command and it will create a file with the output. If you append >>output.txt then you can append to your output file from the previous command. It is a handy feature as your terminal may not go back as far as needed to view all the outputs.

I copied all the media for a backup before running the image removal command.

Any chance you’d be willing to turn this into a mini-review covering:

  • What it does
  • How to use it
  • How it works

Maybe even a screenshot?

Then I could move this from a standalone post to the #reviews:community-written-reviews Section. Assuming you’ve used this yourself…

If not, then I might consider moving this recommendation into a dedicated M1 > M2 post at some point.

I’ll be interested to try this out, especially the attribute clean up. I have a huge SQL query in M1 to do this but it takes forever to complete.

I think it is worth taking a look at, definitely.