equal
deleted
inserted
replaced
|
1 from optparse import make_option |
|
2 |
1 from django.core.management.base import AppCommand |
3 from django.core.management.base import AppCommand |
|
4 from django.core.management.sql import sql_indexes |
|
5 from django.db import connections, DEFAULT_DB_ALIAS |
2 |
6 |
3 class Command(AppCommand): |
7 class Command(AppCommand): |
4 help = "Prints the CREATE INDEX SQL statements for the given model module name(s)." |
8 help = "Prints the CREATE INDEX SQL statements for the given model module name(s)." |
5 |
9 |
|
10 option_list = AppCommand.option_list + ( |
|
11 make_option('--database', action='store', dest='database', |
|
12 default=DEFAULT_DB_ALIAS, help='Nominates a database to print the ' |
|
13 'SQL for. Defaults to the "default" database.'), |
|
14 |
|
15 ) |
|
16 |
6 output_transaction = True |
17 output_transaction = True |
7 |
18 |
8 def handle_app(self, app, **options): |
19 def handle_app(self, app, **options): |
9 from django.core.management.sql import sql_indexes |
20 return u'\n'.join(sql_indexes(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8') |
10 return u'\n'.join(sql_indexes(app, self.style)).encode('utf-8') |
|