Template based on @fastapi_production_template and @djangorestframework-simplejwt
cp .env.example .envdocker-compose up -d --build
Format the code
docker compose exec app format- Create an automatic migration from changes in
src/database.py
docker compose exec app makemigrations *migration_name*- Run migrations
docker compose exec app migrate- Downgrade migrations
docker compose exec app downgrade -1 # or -2 or base or hash of the migrationAll tests are integrational and require DB connection.
One of the choices I've made is to use default database (postgres), separated from app's app database.
- Using default database makes it easier to run tests in CI/CD environments, since there is no need to setup additional databases
- Tests are run with
force_rollback=True, i.e. every transaction made is then reverted
Run tests
docker compose exec app pytest