In the beginning of my website, i didn't know much about drupal and i played a lot with different modules. Now the site is up and running and there are a lot of modules that aren't needed so i disabled them en deleted them from the server... question i have about this: is everything also deleted from the DB or does the nodes that are created with the modules stay in the DB? If so, is there a module or sql script that cleans up the DB?

Comments

WillieBHines’s picture

I'm in the same boat. I've just decided to leave all those tables. They're nearly empty or empty anyway, so they're not taking up space.

I believe in Drupal 5.0 there's gonna be an "uninstall" hook or something that lets the module take out its tables if the module is uninstalled or something. But I think you might be stuck right now.

vm’s picture

You could go through each module and in the .install file or .mysql file find and find the sql it inserted and then remove the sql from the db manually. Keep in mind also that not all modules do something to the database.

an example of how to drop a table from the db for a specific module is as follows.
if you installed and used the word filter module, you would have ran .mysql that inserted the table called wordfilter into your db using this.

CREATE TABLE wordfilter (
  id int(11) auto_increment,
  words varchar(255) DEFAULT '' NOT NULL,
  replacement varchar(255) DEFAULT '' NOT NULL,
  standalone tinyint(1) DEFAULT '0' NOT NULL,
  PRIMARY KEY (id)
);

to remove that table you would do this

DROP TABLE IF EXISTS wordfilter;
mj2308’s picture

you can do this through phpmyadmin as well if you have that..

Remember that you have to delete the entry in the 'system' table as well

TheFazz’s picture

is there a better way to do this?

i too have lots of unused mysql tables in my site's DB. these tables remain perhaps due to unclean uninstall etc. is there a way that i can clean up the DB more easily and without having to risk manual errors?

vm’s picture

not that I am aware of. It's another one of the reasons that testing of modules and such should be done on a test site.

TheFazz’s picture

thanks for the response.

would it therefore be possible for me to compare the database schema of a clean site with only the selected modules installed, and then delete those from the main site's database tables that are not relevent?

is the system table the only other area i will need to manually clean up?

john.kenney’s picture

i came across it the other day - to do exactly what you are asking: clean up DB tables after removing modules. But...I can't recall the name. i came across it while figuring out how to purge old reversions of nodes cause my DBs were getting over large.

i will look again and see if i can find for you.

john.kenney’s picture

found it again. http://drupal.org/project/system_table_cleaner

but i hadn't read it too closely. might do what you want, but looks a bit under maintained.

TheFazz’s picture

john_kenney

thanks for this. it looks like this module is "for advanced users" - got me scared there. i'll have a look further though.