Skip to content

Conversation

@valentijnscholten
Copy link
Member

@valentijnscholten valentijnscholten commented Jan 21, 2026

Summary

This PR adds django-linear-migrations to DefectDojo to maintain a linear migration history and prevent merge migration conflicts.

This will provide two benefits:

  • Prevent accidental merging of PRs with multiple leaf migrations or conflicting migrations
  • Provide an easy manage rebase-migration command to fix it locally and push the branch/PR. --> UPDATE: while testing this I realized this is quite complicated and manual resolution is much easier.

What Changed

  • Updated settings.dist.py to conditionally load the package when DEBUG=True (development only)
  • Updated docker-compose.override.dev.yml to use target: development for all containers
  • Added comprehensive documentation in CONTRIBUTING.md for resolving migration conflicts
  • Added documentation in AGENTS.md for AI agents
  • Created dojo/db_migrations/max_migration.txt tracking file

How It Works

  • Transparent: Developers continue using makemigrations as normal - it automatically updates max_migration.txt
  • Development only: Only loaded when DEBUG=True, following the same pattern as django-debug-toolbar
  • Conflict resolution: When migration conflicts occur, use python manage.py rebase_migration dojo to automatically fix them

@github-actions github-actions bot added docker New Migration Adding a new migration file. Take care when merging. settings_changes Needs changes to settings.py based on changes in settings.dist.py included in this PR docs labels Jan 21, 2026
@valentijnscholten valentijnscholten marked this pull request as draft January 21, 2026 21:14
@valentijnscholten valentijnscholten marked this pull request as ready for review January 21, 2026 21:54
Copy link
Contributor

@mtesauro mtesauro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docker docs New Migration Adding a new migration file. Take care when merging. settings_changes Needs changes to settings.py based on changes in settings.dist.py included in this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants