Add sqldropindexes to manage

Change patch from https://code.djangoproject.com/ticket/5568
to work on modern Django.
Add special case for MySQL which has different syntax for DROP INDEX.
Add unit tests for the new functionality.
This commit is contained in:
Tomasz Rybak 2013-02-23 17:07:50 +01:00
parent 6bbf4e57c8
commit d7429defe6
6 changed files with 111 additions and 2 deletions

View file

@ -2,7 +2,7 @@ from __future__ import unicode_literals
from django.core.management.color import no_style
from django.core.management.sql import (sql_create, sql_delete, sql_indexes,
sql_all)
sql_destroy_indexes, sql_all)
from django.db import connections, DEFAULT_DB_ALIAS, models
from django.test import TestCase
from django.utils import six
@ -36,6 +36,13 @@ class SQLCommandsTestCase(TestCase):
self.assertIn(len(output), [1, 2])
self.assertTrue(output[0].startswith("CREATE INDEX"))
def test_sql_destroy_indexes(self):
app = models.get_app('commands_sql')
output = sql_destroy_indexes(app, no_style(), connections[DEFAULT_DB_ALIAS])
# PostgreSQL creates two indexes
self.assertIn(len(output), [1, 2])
self.assertTrue(output[0].startswith("DROP INDEX"))
def test_sql_all(self):
app = models.get_app('commands_sql')
output = sql_all(app, no_style(), connections[DEFAULT_DB_ALIAS])