We don't have a task right now that can remove the descendants of a description but leave the parent record intact. If you use the delete descriptions task with a slug as input, it will remove descendants in addition to the target parent, but you'd have to manually recreate the parent record that way. See:
There is also a task that will delete draft descriptions - so if the descendants of your target record were the ONLY draft descriptions in your AtoM instance, then that could work as well:
Finally, if you are feeling confident, you could try to delete the descriptions using SQL. A couple of caveats before proceeding:
- DO NOT PROCEED without making a backup of your data first!
- If there are lower-level descendants (i.e. if the children have children), the following query will ONLY work for 2.6! By this I mean that if the children you are trying to delete ALSO have child records of their own (for example, you want to delete a bunch of files in a series, but some or all of those file-level records have item-level children), then only use this query if you are on 2.6. We made some changes in 2.6 to better handle these kinds of cascading operations (see #10306), but in 2.5 and earlier, this could leave corrupted data in your system as these records would be left without a parent ID, and even top-level descriptions in AtoM have a parent_id value of 1 (they are attached to an internal root record not shown in the user interface)
- This is provided as an untested suggestion by myself as an individual. Artefactual takes no responsibility for the outcome!
I did test this once internally and run it by a developer, but in general, Artefactual does not advise messing with AtoM data directly via SQL, so proceed at your own risk!
You will need to access the MySQL command prompt, which means you will need to know the database username and password used during installation. Tips on how to find this information, and how to open the MySQL command prompt, can be found here:
First we'll need to find out the object ID of the parent description. We can do that with the following if we know the slug:
- SELECT object_id FROM slug WHERE slug='your-slug-here';
Replace your-slug-here with the slug of the target parent description whose children you want to delete. See:
Once we have the object ID, we can now use that in a command to delete any records that have that ID set as the parent ID value. In this case, we want to delete directly from the object table - most main entity types in AtoM have a record in this table, where the object ID is originally created, and deleting from here ensures that the deletion will cascade across any associated tables (such as information_object, information_object_i18n, note and note_i18n, property and property_i18n, etc...).
- DELETE o FROM object o JOIN information_object io ON o.id = io.id WHERE io.parent_id='XXXXX';
Replace XXXXX in the example above with the object ID you got from the first query.
After you've done this you'll want to clear the application cache, restart PHP-FPM, rebuild the nested set, and repopulate the search index.
You may also want to clear your web browser cache before checking on the results, to ensure you are seeing an up-to-date version of the page.
Good luck, and if you try it, let us know how it goes!