#28438: Initial migration creates fields not listed in the migration if mixin
class
changes
-------------------------------------+-------------------------------------
Reporter: Michal Dabski | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.11
Severity: Normal | Resolution:
Keywords: | Triage Stage:
migration,models,mixin,postgresql | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Andrei Petre):
* keywords: migration,models,mixin,sql =>
migration,models,mixin,postgresql
Comment:
Hi Michal,
I'm not sure why the `bases=...` is added when you have a non-abstract
base class that doesn't extend from `models.Model`. Maybe someone more
knowledgable could answer that. I can't find any mention of mixin
[https://docs.djangoproject.com/en/1.11/topics/db/models/#model-
inheritance in inheritance documentation], so I'd probably just use
abstract models [https://stackoverflow.com/questions/3254436/django-model-
mixins-inherit-from-models-model-or-from-object#25817237 as suggested in
this SO post] to avoid going in undocumented territory.
Maybe documentation not to use `object` base class with models could be
added? Or trigger an error if you tried doing that to not shoot yourself
in the foot?
I could reproduce this for `postgres` (worked for `sqlite` since it
generates a new table in 2nd migration and copies every row, instead of
adding a new column; probably inefficient, not the way to go anyway), so
assuming that's what you used.
Also found [https://github.com/tbartelmess/django-model-mixins this github
package], but I'd stay away from it unless I understood what it did, which
I don't haha.
--
Ticket URL: <https://code.djangoproject.com/ticket/28438#comment:5>
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/064.f83286a393a03635f84ca347d533feae%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.