Delete a collection
Learn how to delete a collection
You should delete a collection when it no longer serves a business need. This may be because the business stops storing certain data or an application migrates the data to another collection or external system.
You cannot undo collection deletion. Ensure you don't delete a collection required by your application and that you migrate data before deleting, if needed.
To help prevent accidental deletion, normal deletion through the CLI requires a response to a challenge.
Overview
To delete a collection, you:
- Determine the name of the collection you want to delete.
- Use the CLI delete collection command or the REST API delete collection operation passing the collection's name.
Step-by-step
You want to delete the collection buyers
you created in Create a collection.
Deletion using the CLI with challenge
You request the deletion using the CLI like this:
pvault collection delete --collection buyers
Warning! This operation is irreversible. Type "delete_buyers" to confirm deletion. Confirm:
Type delete_buyers
and press enter. The command response with this message:
Collection buyers deleted successfully.
Deletion using the CLI without challenge
You request the deletion using the CLI without it responding with a challenge using the --force
or -f
flag like this:
pvault collection delete --collection buyers --force
The command response with this message:
INF Collection "buyers" deleted successfully.
INF Command completed successfully
Deletion using the API
You request the deletion using the API like this, noting that with the API there is no challenge:
curl --request DELETE \
--silent \
--url "http://localhost:8123/api/pvlt/1.0/ctl/collections/buyers?reason=Maintenance" \
--header 'Authorization: Bearer pvaultauth' \
--header 'Content-Type: application/json'
If the request is successful, you get a 200 response; there is no other output.