Question

Iv been developing a Magento site for a few months now, during this process I have installed and removed many extensions that themselves have created many tables within my database and files on the server, along with that I've tried building multiple extensions of my own including lots of files.

Im wondering if there is a way to monitor which files are being read and used, and then have the ability to remove any, unused tables, or files.

Basically i just want to clean up the store of unused files and tables.

does anyone know if this has been done before? also where to start looking if it has?

Regards

Was it helpful?

Solution

To my knowledge, there isn't a tool that will "remove all unused extension tables" automagically, as that could potentially be quite dangerous (removing still used, or tables where the extension is just disabled, etc).

If you want to proceed, BACK IT UP, BACK IT UP, BACK IT UP!!. Then, and only then, manually go through the database and look at each table (phpMyAdmin makes this a lot easier). If it starts with an extension's namespace that is not being used (usually table names are like: namespace_module_tablename), look at the table to see if it has current/relevant data in it. There is a handy reference for the Magento DB schema (http://www.magereverse.com/). However, I don't know how familiar you are with Magento DB, and if one is not careful/knowledgeable, you can cause tremendous damage.

If you aren't super familiar with Magento, I would steer you away from doing this operation. Depending on if it is a live store or just your development machine, you could always start over. Then you know it is a good, clean start.

OTHER TIPS

Unused tables don't take up much room and removing them can cause so much more grief on version upgrades than the room you'll save if you're looking to remove any tables that Magento itself creates for Magento modules you've disabled.

As to working with third party modules, since Magento's free, it's best if you set up a separate test server for module installations to see if they're really useful and/or compatible and then install them in your dev installation for running with your website.

That being said, after the fact, every module has a mysql installer script that you can read to see what database changes were made so you can attempt to reverse them out. These usually live in app/code/local/(namespace)/(modulename)/sql/(modulename)_setup/* or app/code/community/(namespace)/(modulename)/sql/(modulename)_setup/*. They will be named along the lines of mysql4-install-*.php or mysql4-upgrade-*.php though any of the above conventions could be broken by third party developers who don't follow the conventions closely.

You can use the SQL code in these to reverse out the changes the module made. Backups highly recommended.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top