Python django.db.migrations.AlterIndexTogether() Examples
The following are 18
code examples of django.db.migrations.AlterIndexTogether().
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
django.db.migrations
, or try the search function
.

Example #1
Source Project: django-sqlserver Author: denisenkom File: test_optimizer.py License: MIT License | 5 votes |
def _test_create_alter_foo_delete_model(self, alter_foo): """ CreateModel, AlterModelTable, AlterUniqueTogether/AlterIndexTogether/ AlterOrderWithRespectTo, and DeleteModel should collapse into nothing. """ self.assertOptimizesTo( [ migrations.CreateModel("Foo", [("name", models.CharField(max_length=255))]), migrations.AlterModelTable("Foo", "woohoo"), alter_foo, migrations.DeleteModel("Foo"), ], [], )
Example #2
Source Project: django-sqlserver Author: denisenkom File: test_optimizer.py License: MIT License | 5 votes |
def test_create_alter_index_delete_model(self): self._test_create_alter_foo_delete_model(migrations.AlterIndexTogether("Foo", [["a", "b"]]))
Example #3
Source Project: django-sqlserver Author: denisenkom File: test_optimizer.py License: MIT License | 5 votes |
def _test_alter_alter_model(self, alter_foo, alter_bar): """ Two AlterUniqueTogether/AlterIndexTogether/AlterOrderWithRespectTo should collapse into the second. """ self.assertOptimizesTo( [ alter_foo, alter_bar, ], [ alter_bar, ], )
Example #4
Source Project: django-sqlserver Author: denisenkom File: test_optimizer.py License: MIT License | 5 votes |
def test_alter_alter_index_model(self): self._test_alter_alter_model( migrations.AlterIndexTogether("Foo", [["a", "b"]]), migrations.AlterIndexTogether("Foo", [["a", "c"]]), )
Example #5
Source Project: django-sqlserver Author: denisenkom File: test_optimizer.py License: MIT License | 5 votes |
def test_create_alter_index_field(self): self._test_create_alter_foo_field(migrations.AlterIndexTogether("Foo", [["a", "b"]]))
Example #6
Source Project: django-sqlserver Author: denisenkom File: test_operations.py License: MIT License | 5 votes |
def test_alter_index_together_remove(self): operation = migrations.AlterIndexTogether("Pony", None) self.assertEqual(operation.describe(), "Alter index_together for Pony (0 constraint(s))")
Example #7
Source Project: djongo Author: nesdis File: test_optimizer.py License: GNU Affero General Public License v3.0 | 5 votes |
def _test_create_alter_foo_delete_model(self, alter_foo): """ CreateModel, AlterModelTable, AlterUniqueTogether/AlterIndexTogether/ AlterOrderWithRespectTo, and DeleteModel should collapse into nothing. """ self.assertOptimizesTo( [ migrations.CreateModel("Foo", [("name", models.CharField(max_length=255))]), migrations.AlterModelTable("Foo", "woohoo"), alter_foo, migrations.DeleteModel("Foo"), ], [], )
Example #8
Source Project: djongo Author: nesdis File: test_optimizer.py License: GNU Affero General Public License v3.0 | 5 votes |
def test_create_alter_index_delete_model(self): self._test_create_alter_foo_delete_model(migrations.AlterIndexTogether("Foo", [["a", "b"]]))
Example #9
Source Project: djongo Author: nesdis File: test_optimizer.py License: GNU Affero General Public License v3.0 | 5 votes |
def _test_alter_alter_model(self, alter_foo, alter_bar): """ Two AlterUniqueTogether/AlterIndexTogether/AlterOrderWithRespectTo should collapse into the second. """ self.assertOptimizesTo( [ alter_foo, alter_bar, ], [ alter_bar, ], )
Example #10
Source Project: djongo Author: nesdis File: test_optimizer.py License: GNU Affero General Public License v3.0 | 5 votes |
def test_alter_alter_index_model(self): self._test_alter_alter_model( migrations.AlterIndexTogether("Foo", [["a", "b"]]), migrations.AlterIndexTogether("Foo", [["a", "c"]]), )
Example #11
Source Project: djongo Author: nesdis File: test_optimizer.py License: GNU Affero General Public License v3.0 | 5 votes |
def test_create_alter_index_field(self): self._test_create_alter_foo_field(migrations.AlterIndexTogether("Foo", [["a", "b"]]))
Example #12
Source Project: djongo Author: nesdis File: test_operations.py License: GNU Affero General Public License v3.0 | 5 votes |
def test_alter_index_together_remove(self): operation = migrations.AlterIndexTogether("Pony", None) self.assertEqual(operation.describe(), "Alter index_together for Pony (0 constraint(s))")
Example #13
Source Project: djongo Author: nesdis File: test_optimizer.py License: GNU Affero General Public License v3.0 | 5 votes |
def _test_create_alter_foo_delete_model(self, alter_foo): """ CreateModel, AlterModelTable, AlterUniqueTogether/AlterIndexTogether/ AlterOrderWithRespectTo, and DeleteModel should collapse into nothing. """ self.assertOptimizesTo( [ migrations.CreateModel("Foo", [("name", models.CharField(max_length=255))]), migrations.AlterModelTable("Foo", "woohoo"), alter_foo, migrations.DeleteModel("Foo"), ], [], )
Example #14
Source Project: djongo Author: nesdis File: test_optimizer.py License: GNU Affero General Public License v3.0 | 5 votes |
def test_create_alter_index_delete_model(self): self._test_create_alter_foo_delete_model(migrations.AlterIndexTogether("Foo", [["a", "b"]]))
Example #15
Source Project: djongo Author: nesdis File: test_optimizer.py License: GNU Affero General Public License v3.0 | 5 votes |
def _test_alter_alter_model(self, alter_foo, alter_bar): """ Two AlterUniqueTogether/AlterIndexTogether/AlterOrderWithRespectTo should collapse into the second. """ self.assertOptimizesTo( [ alter_foo, alter_bar, ], [ alter_bar, ], )
Example #16
Source Project: djongo Author: nesdis File: test_optimizer.py License: GNU Affero General Public License v3.0 | 5 votes |
def test_alter_alter_index_model(self): self._test_alter_alter_model( migrations.AlterIndexTogether("Foo", [["a", "b"]]), migrations.AlterIndexTogether("Foo", [["a", "c"]]), )
Example #17
Source Project: djongo Author: nesdis File: test_operations.py License: GNU Affero General Public License v3.0 | 5 votes |
def test_alter_index_together(self): """ Tests the AlterIndexTogether operation. """ project_state = self.set_up_test_model("test_alinto") # Test the state alteration operation = migrations.AlterIndexTogether("Pony", [("pink", "weight")]) self.assertEqual(operation.describe(), "Alter index_together for Pony (1 constraint(s))") new_state = project_state.clone() operation.state_forwards("test_alinto", new_state) self.assertEqual(len(project_state.models["test_alinto", "pony"].options.get("index_together", set())), 0) self.assertEqual(len(new_state.models["test_alinto", "pony"].options.get("index_together", set())), 1) # Make sure there's no matching index self.assertIndexNotExists("test_alinto_pony", ["pink", "weight"]) # Test the database alteration with connection.schema_editor() as editor: operation.database_forwards("test_alinto", editor, project_state, new_state) self.assertIndexExists("test_alinto_pony", ["pink", "weight"]) # And test reversal with connection.schema_editor() as editor: operation.database_backwards("test_alinto", editor, new_state, project_state) self.assertIndexNotExists("test_alinto_pony", ["pink", "weight"]) # And deconstruction definition = operation.deconstruct() self.assertEqual(definition[0], "AlterIndexTogether") self.assertEqual(definition[1], []) self.assertEqual(definition[2], {'name': "Pony", 'index_together': {("pink", "weight")}})
Example #18
Source Project: djongo Author: nesdis File: test_operations.py License: GNU Affero General Public License v3.0 | 5 votes |
def test_alter_index_together_remove(self): operation = migrations.AlterIndexTogether("Pony", None) self.assertEqual(operation.describe(), "Alter index_together for Pony (0 constraint(s))")