#23564: Django migration fails on unqiue_together with model subclass references ----------------------------+-------------------- Reporter: dbinetti | Owner: nobody Type: Bug | Status: new Component: Migrations | Version: 1.7 Severity: Normal | Keywords: Triage Stage: Unreviewed | Has patch: 0 Easy pickings: 0 | UI/UX: 0 ----------------------------+-------------------- I've searched around and can't find a bug for this behavior, so here goes...
With this model inheritance: {{{ class Account(models.Model): name = models.CharField (...) class Source(models.Model): name = models.CharField(...) account = models.ForeignKey('Account', related_name='sources') class SubSource(Source): uid = models.CharField(...) class Meta: unique_together = ( ("account", "uid"), ) }}} My intended behavior here is to ensure I can only have a single combination of Accounts and (external) SubSources. I may have multiple instances of the same external sub-source on the table if used by different accounts, which is why i'm not simply using `unique` on the `uid` field. I can run `django-admin.py check`, which passes, and `django-admin.py makemigrations`, which passes. But when i try to run `django-admin.py migrate` it fails with: {{{ django.db.utils.ProgrammingError: column "account_id" named in key does not exist }}} the generated migration script looks like this: {{{ # -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations class Migration(migrations.Migration): dependencies = [ <snip> ] operations = [ migrations.AlterUniqueTogether( name='subsource', unique_together=set([('account', 'uid')]), ), ] }}} I'm sorry that I'm not skilled enough to produce an actual test case. Thanks. -- Ticket URL: <https://code.djangoproject.com/ticket/23564> 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 django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/051.3ad341efe103c6e283ce7da121656913%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.