#Database reset via Dokploy

1 messages · Page 1 of 1 (latest)

lost sequoia
#

I’m running Twenty self-hosted in Docker via Dokploy using twentycrm/twenty:latest.

What’s the current correct way to fully reset the database for this kind of hosted setup?

I tried the self-host troubleshooting commands, but npx nx database:reset --configuration=no-seed doesn’t seem to work cleanly in the running server container.

minor ventureBOT
#
Searched database reset self-hosted Docker
#
Searched self-host troubleshooting database reset commands
#

Thinking...

#
Searched self-host troubleshooting unable to log in database reset docker exec
#

Let me look into the recommended approach for resetting the database in a self-hosted Docker setup.Based on the documentation, here is the recommended approach for resetting the database on a self-hosted Docker setup:

The documented method for self-hosted environments involves using docker exec to run commands inside the container. The troubleshooting docs note that the reset command will completely erase your database and recreate it from scratch.

The general steps are:

  1. Back up your database first (if you have any data you want to preserve):
docker exec -it {db_container_name_or_id} pg_dumpall -U {postgres_user} > backup.sql
  1. Run the database reset inside the Twenty server container:
docker exec -it {server_container_name_or_id} npx ts-node ./scripts/setup-db.ts

If that specific script path doesn't exist in the latest image, you can take a more manual approach by resetting at the Postgres level:

  1. Drop and recreate the database directly:
# Stop the Twenty server container first
docker stop {server_container_name_or_id}

# Drop and recreate the DB
docker exec -it {db_container_name_or_id} psql -U {postgres_user} -c "DROP DATABASE IF EXISTS \"default\";"
docker exec -it {db_container_name_or_id} psql -U {postgres_user} -c "DROP DATABASE IF EXISTS \"twenty\";"
docker exec -it {db_container_name_or_id} psql -U {postgres_user} -c "CREATE DATABASE \"default\";"
docker exec -it {db_container_name_or_id} psql -U {postgres_user} -c "CREATE DATABASE \"twenty\";"

# Restart the server — it should run migrations on startup
docker start {server_container_name_or_id}

Replace the database names with whatever your PG_DATABASE_URL points to (commonly default or twenty).