Add id as an AutoNumber(primary_key=True) field and remove the pk from
authorDiane Trout <diane@caltech.edu>
Fri, 23 Jan 2009 02:21:09 +0000 (02:21 +0000)
committerDiane Trout <diane@caltech.edu>
Fri, 23 Jan 2009 02:21:09 +0000 (02:21 +0000)
library_id.

Stanford decided to use library_id as a text field so they could use
library IDs like "SL100". Caltech just used the raw sql id, so the
foreign key reference in experiments_flowcells was expecting a numeric
id, but since the model had the text field as the primary key things
didn't work.

htsworkflow/frontend/samples/models.py

index 34cf26077bf08310d4164cb079c09d485669815e..16ef011c8ae8becead6c729395fb4d12dd28a6d5 100644 (file)
@@ -107,8 +107,8 @@ class Affiliation(models.Model):
     unique_together = (("name", "contact"),)
 
 class Library(models.Model):
-  
-  library_id = models.CharField(max_length=30, primary_key=True, db_index=True)
+  id = models.AutoField(primary_key=True)
+  library_id = models.CharField(max_length=30, db_index=True)
   library_name = models.CharField(max_length=100, unique=True)
   library_species = models.ForeignKey(Species)
   cell_line = models.ForeignKey(Cellline)
@@ -135,7 +135,6 @@ class Library(models.Model):
                                      default='RNA-seq')
   
   creation_date = models.DateField(blank=True, null=True)
-  # made_for = models.ForeignKey(User)
   made_for = models.CharField(max_length=50, blank=True, 
       verbose_name='ChIP/DNA/RNA Made By')
   made_by = models.CharField(max_length=50, blank=True, default="Lorian")