title: Django - Best way to merge two identical apps
body: <p>I recently came onto a project in which we have two applications that are virtually identical. We are using Django 1.4 and Postgresql 8.4. Both models have the following:</p>
  
  <pre><code>  class Author(models.Model):
      person = models.ForeignKey(Person)
      book = models.ForeignKey(Book)
      order = models.PositiveIntegerField(blank=True,null=True)
      institute = models.ForeignKey(Institution,blank=True, null=True)
      rank = models.ForeignKey(Rank,blank=True, null=True)
  
    class Institution(models.Model):
      name = models.CharField(max_length=200)
      parent_institution = models.ForeignKey('self', blank=True, null=True)
      location = models.ForeignKey(Location, blank=False, null=False)
      type = models.ForeignKey(InstitutionType, blank=False, null=False)
  
    class Person(models.Model):
      first_name = models.CharField(max_length=100)
      last_name = models.CharField(max_length=100)
      middle_name = models.CharField(max_length=50,blank=True,null=True)
      gender = models.CharField(max_length=1,choices=GENDER_TYPE,blank=True,null=True)
  
    class InstitutionType(models.Model):
      type = models.CharField(max_length=255)
  </code></pre>
  
  <p>Is there a way to easily merge the two, either through SQL or through Django? I'm not quite sure what the best approach would be. My only issue is that there is a lot of foreign key references. Is there a good way in which you could change the primary keys of one application's table to be higher than the other application (essentially reassign primary keys in the second table starting where the first table ends) and have them trickle down and then eventually merge the two tables? Any sort of feedback would be much appreciated.</p>