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