|
29
|
1 |
from optparse import make_option |
|
|
2 |
|
|
0
|
3 |
from django.core.management.base import NoArgsCommand |
|
29
|
4 |
from django.core.management.sql import sql_flush |
|
|
5 |
from django.db import connections, DEFAULT_DB_ALIAS |
|
0
|
6 |
|
|
|
7 |
class Command(NoArgsCommand): |
|
|
8 |
help = "Returns a list of the SQL statements required to return all tables in the database to the state they were in just after they were installed." |
|
|
9 |
|
|
29
|
10 |
option_list = NoArgsCommand.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 |
|
|
0
|
16 |
output_transaction = True |
|
|
17 |
|
|
|
18 |
def handle_noargs(self, **options): |
|
29
|
19 |
return u'\n'.join(sql_flush(self.style, connections[options.get('database', DEFAULT_DB_ALIAS)], only_django=True)).encode('utf-8') |