ScotchAndSoda
ScotchAndSoda

Reputation: 4171

What is the best approach for migrating one Django app to another

I am working on a Django project where I have to use South to migrate one application to another. I have the old internal message application which I have to replace by another completely different. I was wondering if I could pass by orm, but the old application doesn't exist anymore in the INSTALLED_APPS, so no sense. Does using a SQL procedure is the way to do that? I'd like to keep the application DB type independant at the time.

Upvotes: 0

Views: 107

Answers (2)

ScotchAndSoda
ScotchAndSoda

Reputation: 4171

  1. schemamigration: python manage.py schemamigration myapp (with nullable foreign keys)

  2. datamigration: Django custom sql is my friend -> https://docs.djangoproject.com/en/dev/topics/db/sql/ have made my custom data migration script keeping the project DB independent

  3. remove the old application schema using 2.

  4. (optional) a backwards rescue script

Upvotes: 0

thraxil
thraxil

Reputation: 5171

Django applications are namespaced in the database so you ought to be able to temporarily have both applications installed. I would break it down to about three migrations:

  1. A schemamigration to add the new application. If other applications need to have foreign key relations to the new application, add those and just make sure they are all nullable.
  2. A datamigration to walk the model objects in the old application and create the equivalent ones in the new application.
  3. A schemamigration to remove the old application.

Upvotes: 2

Related Questions