Hey Curtis,

the key of the migration operations ordering is in
https://github.com/django/django/blob/d0a42a14c06e033922f6d51e6384cba53be887b6/django/db/migrations/autodetector.py#L159-L195
as you probably have figured out.

What _could_ work, it's not more than idea w/o much thinking about it,
turning these function calls into a list or whatnot that you can inject
functions into that could do "stuff". Or create a dozen hooks that are
called before/after each of these steps.

The other important part is the MigrationGraph in
https://github.com/django/django/blob/d0a42a14c06e033922f6d51e6384cba53be887b6/django/db/migrations/graph.py#L99
that defines in which order migrations are being applied. Injecting
something there is relatively easy by adding more nodes and dependencies
to the graph. There's no official interface to do so, though.

I hope that already helps.

/Markus

On Sat, Feb 03, 2018 at 08:29:24PM +1100, Curtis Maloney wrote:
Hey,

I've recently written an app that implements a closure tree using views... and in order to make the migrations work as needed you must manually add an entry to the migrations.

Another friend of mine, a recent django convert, was wanting a way to add to the migration script generated when creating certain tables...

And today I realised I wanted quite involved control of how migration actions are written for the idea I was working on...

What I conceived was what I call a MigrationAdapter, which controls at least how create/modify/delete actions for a given object are generated.

I've started looking into the migrations code, and it appears the steps are very much hard-coded [and, it appears, with much painfully learned good reasons]...

Anyone with more familiarity with the migration machinery got input on if this is feasible?

--
Curtis

--
You received this message because you are subscribed to the Google Groups "Django 
developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/12134aff-d37c-2b35-27a2-58d52f9358ff%40tinbrain.net.
For more options, visit https://groups.google.com/d/optout.

--

--
You received this message because you are subscribed to the Google Groups "Django 
developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/20180203125940.dllawwoxiqwchgev%40pyler.local.
For more options, visit https://groups.google.com/d/optout.

Attachment: signature.asc
Description: PGP signature

Reply via email to