Revision: 51
Author: AndreFMiller
Date: Fri Apr 30 16:54:49 2010
Log: Update all models to align their primary keys with the primary keys of
the ccp tables.
- The primary key in the CCP dump is a single column and not a foreign
key.
We want to stop Django from auto-generating the id field and use the
value from the CCP dump, so the id column is explicitly defined:
id = models.IntegerField(unique=True, primary_key=True)
- The primary key in the CCP dump is a composite primary key (more
than one column)
Django does not support composite keys, so here we let Django auto-
create a new id column as a primary key. But to keep the database
consistent, add a constraint:
class Meta:
unique_together = ('type', 'material_type')
- The primary key in the CCP dump is a single column, but it is a
foreign key.
Set the foreign key as a unique value and a primary key in the Django
model. This will stop Django from creating an 'id' field that is not
required.
class InvMetaType(models.Model):
type = models.ForeignKey(InvType,
unique=True, primary_key=True,
related_name='inventorymetatype_type_set')
For more discussion, see:
http://groups.google.com/group/django-eve/browse_thread/thread/52044a145e239c56
http://code.google.com/p/django-eve-db/source/detail?r=51
Modified:
/trunk/eve_db/models/certifications.py
/trunk/eve_db/models/chr.py
/trunk/eve_db/models/inventory.py
/trunk/eve_db/models/map.py
/trunk/eve_db/models/npc.py
/trunk/eve_db/models/station.py
/trunk/eve_db/models/system.py