Modify ↓
Ticket #675 (assigned defect)
incorrectly deleted primary key
| Reported by: | dmitriy@… | Owned by: | andrew |
|---|---|---|---|
| Priority: | major | Milestone: | 1.0 |
| Component: | commands | Version: | unknown |
| Keywords: | Cc: |
Description
I have following models (I have simplified)
class Rule(models.Model):
name = models.CharField(max_length=255)
advertiser = models.ForeignKey('company.Advertiser')
campaign = models.ManyToManyField('campaign.Campaign', through='CampaignRule')
group = models.ForeignKey('RuleGroup', null=True)
class Meta:
unique_together = ('advertiser', 'name')
class AutoRule(Rule):
class Meta:
abstract = True
class KeywordRule(AutoRule):
keyword = models.CharField(max_length=255, blank=False)
required = models.BooleanField(default=True)
case_sensitive = models.BooleanField(default=False)
class RuleGroup(AutoRule):
pass
When I first introduced this structure, the generated schema migration added rule_ptr as a primary key to RuleGroup?, but not to KeywordRule?. I added it manually to both the schema migration and to the frozen schema definition in the following data migration, but now every time I do a schema migration, it generates lines to alter KeywordRule? to remove primary key from rule_ptr.
def forwards(self, orm):
# Changing field 'KeywordRule.rule_ptr'
db.alter_column('score_keywordrule', 'rule_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['score.Rule'], unique=True))
def backwards(self, orm):
# Changing field 'KeywordRule.rule_ptr'
db.alter_column('score_keywordrule', 'rule_ptr_id', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['score.Rule'], unique=True, primary_key=True))
Any advice?
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

Hm, that's very strange - one getting the pointer and the other not. I'll have to look into this after I'm back from holiday.