Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docker-compose.override.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ services:
DD_ADMIN_PASSWORD: "${DD_ADMIN_PASSWORD:-admin}"
DD_EMAIL_URL: "smtp://mailhog:1025"
celeryworker:
build:
context: .
dockerfile: Dockerfile.django-${DEFECT_DOJO_OS:-debian}
target: development
entrypoint: ['/wait-for-it.sh', '${DD_DATABASE_HOST:-postgres}:${DD_DATABASE_PORT:-5432}', '-t', '30', '--', '/entrypoint-celery-worker-dev.sh']
volumes:
- '.:/app:z'
Expand All @@ -24,12 +28,20 @@ services:
DD_DEBUG: 'True'
DD_EMAIL_URL: "smtp://mailhog:1025"
celerybeat:
build:
context: .
dockerfile: Dockerfile.django-${DEFECT_DOJO_OS:-debian}
target: development
volumes:
- '.:/app:z'
environment:
PYTHONWARNINGS: error # We are strict about Warnings during development
DD_DEBUG: 'True'
initializer:
build:
context: .
dockerfile: Dockerfile.django-${DEFECT_DOJO_OS:-debian}
target: development
volumes:
- '.:/app:z'
environment:
Expand Down
1 change: 1 addition & 0 deletions dojo/db_migrations/max_migration.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0257_pghistory_tags_backfill
8 changes: 8 additions & 0 deletions dojo/settings/settings.dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -2061,6 +2061,14 @@ def saml2_attrib_map_format(din):

MIDDLEWARE = ["debug_toolbar.middleware.DebugToolbarMiddleware", *MIDDLEWARE]

# Linear migrations for development
# Helps avoid merge migration conflicts by tracking the latest migration
if DEBUG:
INSTALLED_APPS = (
"django_linear_migrations", # Must be before dojo to override makemigrations
*INSTALLED_APPS,
)

def show_toolbar(request):
return True

Expand Down
13 changes: 13 additions & 0 deletions readme-docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,19 @@ This will result in a new file in the `dojo/db_migrations` folder that can be co
When making downstream database model changes in your fork of Defect Dojo please be aware of the risks of getting out of sync with our upstream migrations.
It requiers proper knowledge of [Django Migrations](https://docs.djangoproject.com/en/5.0/topics/migrations/) to reconcile the migrations before you can upgrade to a newer version of Defect Dojo.

### Linear Migration History

DefectDojo uses [django-linear-migrations](https://github.com/adamchainz/django-linear-migrations) to maintain a linear migration history and avoid merge migration conflicts.

**What this means for you:**
- When you run `makemigrations`, a `max_migration.txt` file is automatically updated in `dojo/db_migrations/`
- This file tracks the latest migration and must be committed along with your migration file
- If you're working on a feature branch and migrations are added to `dev` branch, you may encounter a merge conflict in `max_migration.txt`

**Resolving migration conflicts:**

If you encounter a conflict in `dojo/db_migrations/max_migration.txt` during a rebase or merge, rename the migrations and update max_migrations.txt to contain the name of the latest migration of your branch. You can also try to use the `python manage.py rebase_migration dojo` inside the `uwsgi` container, but that requires some hassling with selective container startup and branch switching.

## Submitting Pull Requests

The following are things to consider before submitting a pull request to
Expand Down
4 changes: 4 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ parameterized==0.9.0

# Development file watching (hot reload)
watchdog==6.0.0

# Migration management - allows for easy rebasing via manage.py rebase_migration
django-linear-migrations==2.19.0