Skip to content

Make uuid field migrations reversible and fix invalid values before adding DB constraint#382

Open
MarcoSteinacher wants to merge 2 commits into
developfrom
fix/uuid_and_member_leave_date_migrations
Open

Make uuid field migrations reversible and fix invalid values before adding DB constraint#382
MarcoSteinacher wants to merge 2 commits into
developfrom
fix/uuid_and_member_leave_date_migrations

Conversation

@MarcoSteinacher

@MarcoSteinacher MarcoSteinacher commented Jul 12, 2026

Copy link
Copy Markdown
Member

Fix migrations:

  • Make migrations of CHAR to UUID fields reversible.
  • Fix invalid values of Member.date_leave before adding a new constraint in order to avoid failing migrations with IntegrityError.

I confirm that I have read the Contributor Agreement v1.1, agree to be bound on them and confirm that my contribution is compliant.

Summary by CodeRabbit

  • Bug Fixes

    • Corrected member records with exit dates earlier than their join dates.
    • Added validation to prevent invalid date ranges.
  • Database Improvements

    • Added rollback support for UUID storage conversions.
    • Improved migration reliability when changes need to be reversed.

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f9983114-397e-4419-abf3-53adf7fbda29

📥 Commits

Reviewing files that changed from the base of the PR and between 86454ee and 3d3b0a7.

📒 Files selected for processing (3)
  • django/geno/migrations/0024_member_name_to_fk_and_date_constraint.py
  • django/geno/migrations/0026_convert_uuids_from_char.py
  • django/report/migrations/0003_convert_uuids_from_char.py

📝 Walkthrough

Walkthrough

The migrations now repair invalid member exit dates before adding a date constraint and define rollback SQL for two UUID column conversions.

Changes

Member date constraint migration

Layer / File(s) Summary
Repair invalid member dates
django/geno/migrations/0024_member_name_to_fk_and_date_constraint.py
Adds a data fix for members whose exit date precedes their join date, then runs it before the existing schema changes.

UUID conversion rollback support

Layer / File(s) Summary
Restore character UUID columns
django/geno/migrations/0026_convert_uuids_from_char.py, django/report/migrations/0003_convert_uuids_from_char.py
Adds reverse SQL to restore random_id and task_id as CHAR(36) columns during migration rollback.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the two main changes: reversible UUID migrations and pre-constraint data cleanup.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/uuid_and_member_leave_date_migrations

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  django/geno/migrations
  0024_member_name_to_fk_and_date_constraint.py 10-14
Project Total  

This report was generated by python-coverage-comment-action

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants