mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Refs #26709 -- Added 'model' argument to SchemaEditor.add/remove_index()
This removes the dependency of the Index class on its model attribute when a name is passed to it. Thanks to Markush for discussions.
This commit is contained in:
parent
3410820460
commit
52442898e7
4 changed files with 20 additions and 18 deletions
|
@ -1455,13 +1455,12 @@ class SchemaTests(TransactionTestCase):
|
|||
self.assertNotIn('title', self.get_indexes(Author._meta.db_table))
|
||||
# Add the index
|
||||
index = Index(fields=['name'], name='author_title_idx')
|
||||
index.model = Author
|
||||
with connection.schema_editor() as editor:
|
||||
editor.add_index(index)
|
||||
editor.add_index(Author, index)
|
||||
self.assertIn('name', self.get_indexes(Author._meta.db_table))
|
||||
# Drop the index
|
||||
with connection.schema_editor() as editor:
|
||||
editor.remove_index(index)
|
||||
editor.remove_index(Author, index)
|
||||
self.assertNotIn('name', self.get_indexes(Author._meta.db_table))
|
||||
|
||||
def test_indexes(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue