#23034: Add migrations support for adding ManyToMany "through" model
-----------------------------+------------------------------------
Reporter: lorinkoz@… | Owner: (none)
Type: New feature | Status: new
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Changes (by Simon Charette):
* owner: Simon Charette => (none)
* status: assigned => new
Comment:
I'm not actively working on this ticket so I'll deassign myself but I made
some progress by using a different approach.
My idea was to teach the auto-detector to detect `ManyToMany(through)`
addition where through is a model compatible with the previously auto-
created model. When it detected this case it would use the questioner to
ask the user whether or not the previous table should be reused. On a
"yes" a `AddManyToManyThrough` operation that has a noop
`database_forwards` but an appropriate `state_forwards` to deal with the
`ModelState` insertion would be added to the operations. If the new
`db_table` wasn't matching or fields were added then the appropriate
`AlterModelTable` and `AddField` operations would be added after the
`AddManyToManyThrough` as well.
`[CreateModel('Foo'), AddManyToManyThrough('Foo', 'bars',
ManyToMany('Bar', through='FooBar')]` could be optimized into
`[CreateModel('Foo'), CreateModel('FooBar', fks), AddField('Foo', 'bars',
ManyToMany('Bar', through='FooBar')]` and the normal chain of
optimizations could then take place.
The work so far is available on this
[https://github.com/django/django/compare/master...charettes:ticket-23034
branch]
--
Ticket URL: <https://code.djangoproject.com/ticket/23034#comment:12>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" 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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/076.a0013b4ef45d2394fa4e143a19b0786a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.