Opened 2 years ago
Closed 2 years ago
#33947 closed Uncategorized (invalid)
Adding db_index to a field inherited from an Abstract class does not propagate the change to the models subclassing it
Reported by: | awiebe | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 3.2 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
I have a bunch of Models of the form
class AbstractOwnershipModel(models.Model): owner_user= models.ForeignKey('auth.User') class Meta: abstract = True class AnOwnedModel(AbstractOwnershipModel): #...
Which I tried to change to
class AbstractOwnershipModel(models.Model): owner_user= models.ForeignKey('auth.User',db_index=True) class Meta: abstract = True
But makemigrations reports that there are no changes even though I would expect a bunch of indexes to be created.
Change History (2)
comment:1 by , 2 years ago
Description: | modified (diff) |
---|
comment:2 by , 2 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
That's because the index is already created by default:
You can check by connecting to the database using
./manage.py dbshell
and looking at the database schema.