Hi there,
To build upon the work that Dylan has already done to override the
auto primary key field for the models I've made a few more changes to
align the primary keys in the Django models with the primary keys on
the CCP dump tables.
But before I commit it I just want to make sure you agree with these
changes.
I've gone though all the models that are currently defined in django-
eve-db and looked up in the latest CCP dump what the primary key
definition is. I added this primary key to the model's doc-string for
future reference.
There are a couple of scenarios:
- 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')
If you agree with this approach, let me know and I will commit it
after I run a test import to make sure there are no failures.
--
You received this message because you are subscribed to the Google Groups "Django and EVE Online" group.
To post to this group, send email to
djang...@googlegroups.com.
To unsubscribe from this group, send email to
django-eve+...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-eve?hl=en.