web/lib/django/core/management/commands/sqlindexes.py
changeset 38 77b6da96e6f1
equal deleted inserted replaced
37:8d941af65caf 38:77b6da96e6f1
       
     1 from optparse import make_option
       
     2 
       
     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
       
     6 
       
     7 class Command(AppCommand):
       
     8     help = "Prints the CREATE INDEX SQL statements for the given model module name(s)."
       
     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 
       
    17     output_transaction = True
       
    18 
       
    19     def handle_app(self, app, **options):
       
    20         return u'\n'.join(sql_indexes(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8')