Database migration
Your back office works by default with a SQLite database. This database is sufficient for small to medium-sized applications, but if you anticipate high traffic on your back office, then it is advisable to migrate to a PostgreSQL database.
New docker compose file
In order to add PostgreSQL to your docker stack, we take the docker-compose.yml file proposed in the getting started guide and add a postgres service to it. We also specify a new environment variable DATABASE_URL.
yaml
name: back-office
services:
postgres:
image: postgres:latest
ports:
- 5432:5432
volumes:
- postgres:/var/lib/postgresql
environment:
POSTGRES_HOST_AUTH_METHOD: trust
web:
image: backofficeapp/back-office:latest
ports:
- 3000:3000
volumes:
- credentials:/back-office/config/credentials
- storage:/back-office/storage
- clamav:/var/lib/clamav
depends_on:
- postgres
environment:
- DATABASE_URL=postgres://postgres@postgres
volumes:
postgres:
credentials:
storage:
clamav:After completing the docker-compose.yml file, we proceed to re-run the command to create the containers:
shell
docker compose up --buildMigration command
Once the postgres service is available in your docker environment, you only need to execute the database migration command. To do this, run the following command:
shell
docker exec -it back-office-web sh -c "bin/postgres"