From 223b2650ad41639849efa71bf5bd894e9ce27eda Mon Sep 17 00:00:00 2001 From: PCoder Date: Tue, 27 Jul 2021 09:38:39 +0530 Subject: [PATCH] Introduce primary keys and remove managed = False from models (Assuming we want to manage these tables using django in future) --- app/models.py | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/app/models.py b/app/models.py index 5d6cd43..1c2916f 100644 --- a/app/models.py +++ b/app/models.py @@ -17,43 +17,41 @@ class AlembicVersion(models.Model): class Field(models.Model): - id = models.AutoField() + id = models.AutoField(primary_key=True) name = models.CharField(blank=True, null=True) class Meta: - managed = False db_table = 'field' class FieldsPeople(models.Model): + id = models.AutoField(primary_key=True) person = models.ForeignKey('Person', models.DO_NOTHING, blank=True, null=True) field = models.ForeignKey(Field, models.DO_NOTHING, blank=True, null=True) class Meta: - managed = False db_table = 'fields_people' class Method(models.Model): - id = models.AutoField() + id = models.AutoField(primary_key=True) name = models.CharField(blank=True, null=True) class Meta: - managed = False db_table = 'method' class MethodsPeople(models.Model): + id = models.AutoField(primary_key=True) person = models.ForeignKey('Person', models.DO_NOTHING, blank=True, null=True) method = models.ForeignKey(Method, models.DO_NOTHING, blank=True, null=True) class Meta: - managed = False db_table = 'methods_people' class Person(models.Model): - id = models.AutoField() + id = models.AutoField(primary_key=True) source_id = models.IntegerField(blank=True, null=True) title = models.CharField(blank=True, null=True) first_name = models.CharField(blank=True, null=True) @@ -67,33 +65,31 @@ class Person(models.Model): field_indexer = models.TextField(db_column='_indexer', blank=True, null=True) # Field renamed because it started with '_'. class Meta: - managed = False db_table = 'person' class Range(models.Model): - id = models.AutoField() + id = models.AutoField(primary_key=True) source_id = models.IntegerField(blank=True, null=True) gmba_id = models.CharField(blank=True, null=True) name = models.CharField(blank=True, null=True) countries = models.CharField(blank=True, null=True) class Meta: - managed = False db_table = 'range' class RangesPeople(models.Model): + id = models.AutoField(primary_key=True) person = models.ForeignKey(Person, models.DO_NOTHING, blank=True, null=True) range = models.ForeignKey(Range, models.DO_NOTHING, blank=True, null=True) class Meta: - managed = False db_table = 'ranges_people' class Resource(models.Model): - id = models.AutoField() + id = models.AutoField(primary_key=True) source_id = models.IntegerField(blank=True, null=True) title = models.CharField(blank=True, null=True) url = models.CharField(blank=True, null=True) @@ -101,50 +97,47 @@ class Resource(models.Model): abstract = models.TextField(blank=True, null=True) class Meta: - managed = False db_table = 'resource' class ResourcesPeople(models.Model): + id = models.AutoField(primary_key=True) person = models.ForeignKey(Person, models.DO_NOTHING, blank=True, null=True) resource = models.ForeignKey(Resource, models.DO_NOTHING, blank=True, null=True) class Meta: - managed = False db_table = 'resources_people' class Scale(models.Model): - id = models.AutoField() + id = models.AutoField(primary_key=True) name = models.CharField(blank=True, null=True) class Meta: - managed = False db_table = 'scale' class ScalesPeople(models.Model): + id = models.AutoField(primary_key=True) person = models.ForeignKey(Person, models.DO_NOTHING, blank=True, null=True) scale = models.ForeignKey(Scale, models.DO_NOTHING, blank=True, null=True) class Meta: - managed = False db_table = 'scales_people' class TaxaPeople(models.Model): + id = models.AutoField(primary_key=True) person = models.ForeignKey(Person, models.DO_NOTHING, blank=True, null=True) taxon = models.ForeignKey('Taxon', models.DO_NOTHING, blank=True, null=True) class Meta: - managed = False db_table = 'taxa_people' class Taxon(models.Model): - id = models.AutoField() + id = models.AutoField(primary_key=True) name = models.CharField(blank=True, null=True) class Meta: - managed = False db_table = 'taxon'