Need to clear ODK central projects and data

Is there a way to clean out all the projects and data on a Central install? Or does someone familiar with docker know a command to run? I have a demo/sandbox server and I want it fresh between groups of people I show it to. What's the quickest way to get that?

Hi @danbjoseph!

This isn't possible at the moment using the frontend alone. For example, forms can be deleted in the frontend, but project's can't. (There's been some discussion around project deletion here.)

That said, project deletion is possible using the API. So one option for you might be to delete projects using the API, then retire web users using the frontend or API. In most ways, Central would then look like it does after it is first installed. However, there would be some differences. For example, the server audit logs would continue to show past activity.

Would that be enough for the demo? There might also be a Docker command to reset the database, which @issa would know.

Thanks @Matthew_White!

Ah, I missed the developer documentation for Central and was only looking at the main documentation site.

This looks like what I need?
https://odkcentral.docs.apiary.io/#reference/project-management/projects/deleting-a-project
Is the data cleared and the storage space freed up? Or just the Central server completely forgets about it?

Yes, I think that's right! Using curl, it'd be something like:

# Create a new session. You will use the resulting token in the next request.
curl -X POST -H 'Content-Type: application/json' -d '{ "email": "[YOUR EMAIL]", "password": "[YOUR PASSWORD]" }' https://sandbox.central.opendatakit.org/v1/sessions

# Delete the project. You can find a project's id by navigating to the project
# in the frontend: the id will be the number at the end of the URL (for example,
# https://sandbox.central.opendatakit.org/#/projects/1).
curl -X DELETE -H 'Authorization: Bearer [TOKEN]' https://sandbox.central.opendatakit.org/v1/projects/[PROJECT ID]

At least as the endpoint is implemented right now, it's more like the latter. The project will be soft-deleted and will still exist in the database (along with its forms and submissions). The project should still show up in the server audit logs. However, it will not be accessible using the frontend or the project management endpoints of the API.

yes, it will only be forgotten about. when enough people complain about needing to reclaim storage space, we can add a mechanism to prune old (>60 days?) deleted Things from the database automatically.

there is no direct command to entirely clear the database, though if you do something like docker-compose rm postgres that'll more or less accomplish the same thing (you'll have to docker-compose build postgres again after).

1 Like