2012-06-08 00:08:47 +08:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2014-06-18 07:07:54 +08:00
|
|
|
from django.core.management.base import BaseCommand
|
2009-12-22 23:18:51 +08:00
|
|
|
from django.core.management.sql import sql_flush
|
2015-01-28 20:35:27 +08:00
|
|
|
from django.db import DEFAULT_DB_ALIAS, connections
|
2007-08-16 14:06:55 +08:00
|
|
|
|
2013-11-03 04:12:09 +08:00
|
|
|
|
2014-06-18 07:07:54 +08:00
|
|
|
class Command(BaseCommand):
|
2014-09-04 20:15:09 +08:00
|
|
|
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."
|
|
|
|
)
|
2007-08-16 14:06:55 +08:00
|
|
|
|
|
|
|
output_transaction = True
|
|
|
|
|
2014-06-07 04:39:33 +08:00
|
|
|
def add_arguments(self, parser):
|
|
|
|
super(Command, self).add_arguments(parser)
|
|
|
|
parser.add_argument('--database', default=DEFAULT_DB_ALIAS,
|
|
|
|
help='Nominates a database to print the SQL for. Defaults to the '
|
|
|
|
'"default" database.')
|
|
|
|
|
2014-06-18 07:07:54 +08:00
|
|
|
def handle(self, **options):
|
2014-06-07 04:39:33 +08:00
|
|
|
return '\n'.join(sql_flush(self.style, connections[options['database']], only_django=True))
|