mirror of
https://github.com/django/django.git
synced 2025-07-23 05:05:17 +00:00
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:
parent
6bbf4e57c8
commit
d7429defe6
6 changed files with 111 additions and 2 deletions
|
@ -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])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue