|
29
|
1 |
from optparse import make_option |
|
|
2 |
|
|
0
|
3 |
from django.core.management.base import AppCommand |
|
29
|
4 |
from django.core.management.sql import sql_reset |
|
|
5 |
from django.db import connections, DEFAULT_DB_ALIAS |
|
0
|
6 |
|
|
|
7 |
class Command(AppCommand): |
|
|
8 |
help = "Prints the DROP TABLE SQL, then the CREATE TABLE SQL, for the given app name(s)." |
|
|
9 |
|
|
29
|
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 |
|
|
0
|
17 |
output_transaction = True |
|
|
18 |
|
|
|
19 |
def handle_app(self, app, **options): |
|
29
|
20 |
return u'\n'.join(sql_reset(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8') |