> For the complete documentation index, see [llms.txt](https://ofn-user-guide.gitbook.io/ofn-testing-handbook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ofn-user-guide.gitbook.io/ofn-testing-handbook/testers-toolkit/reverting-database-changes.md).

# Reverting Database Changes

Sometimes a staging database gets changed by pull requests which are not finished yet. Those changes should be reverted and some of these changes may actually break the application. So here are a couple of scripts for testers to execute on the server.

## Log into the staging server with ssh and run these:

* This command will save the DB in its current state. It should be used when we know the DB is in a healthy state.

`~/apps/openfoodnetwork/current/script/ci/save-staging-baseline.sh`

* This command will restore the DB to its previously saved state. It can be used after changing or eventually having corrupted the DB; it will revert those changes. **Notice that running this may lead to the loss of test data**.

`~/apps/openfoodnetwork/current/script/ci/restore-staging-baseline.sh`

* Save baseline data when you have a good pull request that gets merged and you want to keep your test data.

Reference: See also [the PR](https://github.com/openfoodfoundation/openfoodnetwork/pull/12947) which introduced these changes.
