Here\'s what I want to do.
Develop a Django project on a development server with a development database. Run the south migrations as necessary when I change the model.<
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 BaseCommand
from django import db
class 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