Django - South - Is There a way to view the SQL it runs?
You can at least inspect the sql generated by doing manage.py migrate --db-dry-run --verbosity=2
. This will not do anything to the database and will show all the sql. I would still make a backup though, better safe than sorry.
You could try logging the SQL queries in db.connection.queries, using a management command that calls the migrate with a dry-run option:
from django.core.management.base import BaseCommandfrom django import dbclass Command(BaseCommand): help = 'Output SQL for migration' def handle(self, *app_labels, **options): # assumes DEBUG is True in settings db.reset_queries() from django.core.management import call_command kw = {'db-dry-run': 1, 'verbosity': 0} call_command('migrate', **kw) for query in db.connection.queries: print query['sql']
Assuming that south puts everything through the usual db interface that should work. There will be a few extra selects in there when it queries the history table.
You'd put that in a management/commands/print_migration_sql.py
inside your app and then run it:
python manage.py print_migration_sql
It could probably be easily extended to run this only for specific apps etc