Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add django-migration-git-conflict to prevent divergent migration merges #4075

Merged
merged 1 commit into from
Apr 16, 2024

Conversation

sarayourfriend
Copy link
Collaborator

Fixes

Fixes #687 by @sarayourfriend

Description

Adds django-migration-git-conflict recommended in this comment by @tylerlaprade (thanks!).

Check out the plugin's repository for information on how it works: https://github.com/crux-lab/django-migrations-git-conflicts?tab=readme-ov-file#how-it-works

To summarise: the latest migration files for each app will get updated when a new migration is added. When that file is merged, any other branches with divergent latest migrations will conflict, and need a rebase to fix.

Existing CI checks should all continue to work, and we can leave in the PR comment requesting a rebase for migrations anyway, as an additional helpful reminder. Ideally PRs with migrations are always rebased even without a conflict so that the migrated code is tested against main, in case there are issues with new code unaware of the migration changes (i.e., a semantic conflict). But we are always vulnerable to those, even outside the context of a migration, so I don't think we should consider them a special case with respect to the linked issue.

Testing Instructions

Review the new files. Run just api/dj makemigrations --check locally and see that it works. Make a change to force a migration (change some help text on a model attribute, for example) and run makemigrations again, confirm that the latest migration is updated. All of that is really just showing how the plugin works, we don't need to test the plugin.

Checklist

  • My pull request has a descriptive title (not a vague title likeUpdate index.md).
  • My pull request targets the default branch of the repository (main) or a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • [N/A] I added or updated tests for the changes I made (if applicable).
  • [N/A] I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.
  • [N/A] I ran the DAG documentation generator (if applicable).

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@sarayourfriend sarayourfriend requested a review from a team as a code owner April 9, 2024 01:59
@sarayourfriend sarayourfriend added 🟨 priority: medium Not blocking but should be addressed soon 🤖 aspect: dx Concerns developers' experience with the codebase 🧰 goal: internal improvement Improvement that benefits maintainers, not users 🧱 stack: api Related to the Django API labels Apr 9, 2024
Copy link
Member

@dhruvkb dhruvkb left a comment

Choose a reason for hiding this comment

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

LGTM, except that Pipenv has, once again, updated a ton of unrelated dependencies. Please see if it is possible to reduce the extent of the updates, but if not, I don't mind.

@sarayourfriend
Copy link
Collaborator Author

Oh gosh 🤦 I thought I checked to make sure, but I think I forgot to re-do it when I had to re-install the dependency locally due to a misconfiguration thing on my end. I'll go through it again, thank you for catching it.

Copy link
Collaborator

@stacimc stacimc left a comment

Choose a reason for hiding this comment

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

TIL, very cool plugin. LGTM!

Copy link
Collaborator

@AetherUnbound AetherUnbound left a comment

Choose a reason for hiding this comment

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

Applying a change requested review just so we don't accidentally merge this PR which updates dependencies where we might affect production!

@dhruvkb
Copy link
Member

dhruvkb commented Apr 11, 2024

I was not requesting changes because it seems like the package upgrades are OK now that #4032 was merged. As far as I can tell, there are now no occurrences of asyncio tasks being created.

@sarayourfriend sarayourfriend force-pushed the add/git-migration-conflict branch from 5ca5e39 to e2818fa Compare April 16, 2024 02:34
@WordPress WordPress deleted a comment from github-actions bot Apr 16, 2024
Copy link

This PR has migrations. Please rebase it before merging to ensure that conflicting migrations are not introduced.

@sarayourfriend sarayourfriend merged commit 173686e into main Apr 16, 2024
49 checks passed
@sarayourfriend sarayourfriend deleted the add/git-migration-conflict branch April 16, 2024 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖 aspect: dx Concerns developers' experience with the codebase 🧰 goal: internal improvement Improvement that benefits maintainers, not users 🟨 priority: medium Not blocking but should be addressed soon 🧱 stack: api Related to the Django API
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Prevent divergent migrations from being merged by concurrent, not-rebased PRs
4 participants