[Answer]-South data migration update across tables

1👍

The fastest way to do this migration is to use raw SQL query.

I don’t know if your database supports UPDATE ... FROM ... JOIN syntax but the following UPDATE ... SELECT should work almost on every db-server.

from south.db import db
db.execute("""
    UPDATE app_digitalproductformat
    SET checksum = (SELECT checksum FROM app_image
                    WHERE app_image.id=app_digitalproductformat.image_id)
    WHERE image_id IS NOT NULL
           """)

Where app is the name of your django app.

Leave a comment