How to reset database on Coolify docker compose app

This one is a big specific. I recently squashed the database migrations for an app that have pivoted a lot of times, leading to things being added, removed, and re-added to the schema. To get a cleaner source code record, I decided to squash the schema. I could do this because the app was not in production yet. However, I had the app running in test with Coolify on a VPS, so needed a clean slate there.

These are the steps I took to reset the database.

  1. Stop the application via the Coolify interface
  2. Delete the database volume in Docker (see commands below)
  3. Redeploy the application (recreates the database volume)

Delete the database volume in Docker:

# SSH into the Coolify server
ssh [user]@[VPS IP]
# Delete volume
sudo docker volume rm DATABASE_VOLUME_NAME

How to find the right volume to delete:

# List all volumes (ignore Coolify's own volumes)
sudo docker volume ls | grep -vi coolify
# Check that volume is attached to container (must run before stopping, since Coolify prunes containers)
sudo docker ps -a --filter volume=[NAME OF LIKELY VOLUME]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.