简体   繁体   中英

Django (pre1.7) management command to run the customsql for an app

Django (pre 1.7 and pre-the new migration functionality), has a management command sqlcustom to display the custom SQL that would be run for an app. However that prints it to the terminal. Is there any single django management command to actually run all the migrations?

I'm using a Django pre1.7 project which uses South for migrations, and we have some custom SQL (for sql views), and I want to have all the database stuff done via migrations. Custom SQL is loaded by syncdb on vanilla Django, but when you use South, it overrides syncdb and doesn't run custom sql. I'd like to create a South migration for an app that is really simple and calls this management command to load the custom SQL. (You can call django management commands from inside python ). I don't want to duplicate the SQL inside the migration.

You can pipe the output of sqlcustom to dbshell . Something like this:

django-admin.py sqlcustom myapp > django-admin.py dbshell

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM