Hi there,

I've been learning Drupal and building a local site for about 5 weeks now. I'm nearly ready to go live, but have a few questions:

1. While learning, I installed, and subsequently un-installed a lot of Modules and Themes. I see that some of them left their dirty washing in my Database. Is there a way to clean up and remove these orphan tables from my Database?

2. Similarly, is there a simple way to pinpoint orphan files in my Drupal folder? For example, images and CSS files installed by no-longer existing Themes?

3. I won't be using any of the Themes in Drupal's default "Themes" folder ("drupal-5.1/themes"). Is it safe to delete the contents? Any good reason not to?

Any input or pointers will be much appreciated!

--
Jim

Drupal 5.1, MAMP 1.4.1
Mac OS 10.4.8, Apache 2.0.59, MySQL 5.0.19, PHP 5.1.6

Comments

dman’s picture

Only as of really recently has there been an uninstall hook added.
... and I've not yet seen any modules which use it!
Thus, there's no tidy way to do it.
You can try pruning the tables you recognise as being totally owned by unused modules, but take care. I'd suggest double-checking the .install files of the modules your are purging - that will list the database tables they created. No easier way than that. :(

Having dead tables available is messy, but should not actually affect anything.
Also to clean up, however, is yout variables table, which may now contain some cruft, and will load once for every page.
So you can go into the DB and zap any rows from the 'variables' table you don't like. That is actually pretty safe, as the system will fall back to the defaults and regenerate anything it still needs - if you get too trigger-happy.

Installs should NOT have placed any files in your system folders. Some may have created some placeholders under your 'files/' directory, but you should not need to go hunting for files outside the modules dir itself.
Note that many older install instructions say to place your modules in the /modules directory. This practice is deprecated and you should instead place your modules in /sites/[sitename|all]/modules/* instead. Only when it comes to cleaning up do you realize how much sense that extra step makes. You'll know for next time :-}

Yes, you can delete the redundant themes. Best to leave the default Garland around for disaster recovery however.

.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/

hbar’s picture

Hi .dan,

That's exactly the kind of information I was looking for! It's very much appreciated. :-)

Luckily, I came to Drupal at version 5.1, so I have been placing all my modules in /sites/[sitename|all]/modules/. I didn't know why then, but I do now!

Thanks again for your reply.

Jim

nancydru’s picture

All my modules have uninstall functions, and I have contributed some to other modules as well.

Dead tables can affect the ability to upload/download the database back up because of their size. After cleaning up the tables and other things it is also useful to use Optimize on all tables with overhead.

Another thing to look at is the Variable table - it contains the system variables used by the modules. There's a very high likelihood that there is a bunch of left over junk in there.

If you played with different themes, you probably have a lot of left-over blocks in you blocks table. You can delete the themes, but I do suggest keeping one of the default themes around, just in case. I usually keep both Bluemarine and Garland. They also are there in case you need to debug some arcane problem that may or may not be theme related.

Before you do your final back up to load to the live site, truncate the cache and watchdog tables to reduce the size.

Something that might help you figure out all the junk is the Site Documentation module that I just uploaded (it will take a few hours to show up). It will show you all kinds of stuff and even delete some of it for you. Check http://drupal.org/node/144837 to see if you're interested.

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database

hbar’s picture

This is great information. I'm totally green when it comes to Apache/MySQL/PHP, so all this help is really useful. :-)

I've just downloaded your Site Documentation module. Looks very useful.

Thanks a lot!
--

Jim

hbar’s picture

Aha! I just found http://drupal.org/project/content_type_cleanup (released today, in fact), which looks like it might help.

sepeck’s picture

Click the best practices link in my sig. Make sure before you go live and BEFORE YOU START DROPPING TABLES that you know how to backup and restore your site successfully and you document it. File level and database.

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide -|- Black Mountain

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide

hbar’s picture

Hi Steven,

Thanks for the Drupal Best Practices Guide. I did in fact read this when I started with Drupal, but didn't really know enough then. I think a re-read is in order!

I will follow your advice and try to backup and restore my Drupal folder and database before going live, but I'm a little nervous about messing something up, and restoring a dodgy version on top of a functioning version. I guess I'll have to read your guide and then spend some time reading the Handbooks and browsing these forums.

Thanks for your help and advice. :-)
--

Jim