Development Tip: Leave Only Footprints

Here's a quick tip for newbie module builders (like myself).

The process of development is likely to involve many installs, as well as many uninstalls, of your new module. If you're doing this right, you'll have a hook_uninstall() function in your .install file that cleans out any DB tables you've added.

But it might also help -- at least for development purposes -- to do even more house cleaning upon uninstalling a module. For example, in the module I'm developing, I also remove any new nodes I've added in the process (so I don't keep filling the node table with every install). Something like:

function delete_all_NEW_NODE_TYPE_nodes() {
	$nodes = db_query("SELECT nid FROM {node} WHERE type='NEW_NODE_TYPE'");
	while ($node = db_fetch_array($nodes)) {
		node_delete($node['nid']);
	}
}

will help keep your dev DB nice and pristine!