The content module implements a hook_node_type $op for delete, where it deletes the type tables, but it never deletes the field tables. The attached patch checks in content_field_instance_delete for when the $instances drops below 0 and then deletes {content_field_} tables.

I ran into this problem when I implemented a new module that uses CCK to store it's data. I create the CCK node types on hook_install and delete them on hook_uninstall. But because of the above problem, subsequent installs didn't work because the field tables still existed.

CommentFileSizeAuthor
node_type_delete_4.patch2.17 KBdouggreen

Comments

karens’s picture

Status: Needs review » Closed (duplicate)

This is part of a bigger problem. See http://drupal.org/node/97861. I'm currently working on a fix for the 6.x version. We won't get a complete solution in 5.x, but we could at least drop these tables.

Just to keep this topic in one place, let's move the discussion over there.

karens’s picture

More digging into this issue... Those tables should have been uninstalled in the normal process and your code should be unnecessary, but the reason they weren't is not that there was no provision to remove the tables, but that once you disable your module (which obviously happens prior to uninstalling it) info about those tables is no longer available to CCK so it didn't know there was a table to delete. I'm working on a fix for this whole messy thing in 6.x (in the link I posted above) and then hopefully we can backport some (but probably not all) of the fix to 5.x.