I'm working on a pretty complex Django project (50+ models) with some complicated logic (lots of different workflows, views, signals, APIs, background tasks etc.). Let's call this project-base
. Currently using Django 1.6 + South migrations and quite a few other 3rd party apps.
Now, one of the requirements is to create a fork of this project that will add some fields/models here and there and some extra logic on top of that. Let's call this project-fork
. Most of the extra work will be on top of the existing models, but there will also be a few new ones.
As project-base
continues to be developed, we want these features to also get into project-fork
(much like a rebase/merge in git-land). The extra changes in project-fork
will not be merged back into project-base
.
What could be the best possible way to accomplish this? Here are some of my ideas:
Use South merges in project-fork
to keep it up-to-date with latest changes from project-base
, as explained here. Use signals and any other means necessarry to keep the new logic from project-fork
as loosely coupled as possible to avoid any potential conflicts.
Do not modify ANY of the original project-base
models and instead create new models in different apps that reference the old models (i.e. using OneToOneField
). Extra logic could end up in the old and/or new apps.
your idea here please :)
I would go with option 1 as it seems less complicated as a whole, but might expose a greater risk. Here's how I would see it happening:
Migrations on project-base
:
Migrations on project-fork
:
After merge, the migrations would look like this:
Are there any pitfalls using this approach? Is there a better way?
Thank you for your time.
The official South recommendation is to try with the --merge
flag: http://south.readthedocs.org/en/latest/tutorial/part5.html#team-workflow
This obviously won't work in all cases, from my experience it works in most though.
Pitfalls:
The "better" way is usually to avoid simultaneous changes to the same models, the easiest way to do this is by reducing the error-window as much as possible.
With small forks where the model changes are obvious from the beginning:
With large forks where the changes are not always obvious and/or will change again:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With