當前位置: 首頁>>代碼示例>>Python>>正文


Python migrations.AlterIndexTogether方法代碼示例

本文整理匯總了Python中django.db.migrations.AlterIndexTogether方法的典型用法代碼示例。如果您正苦於以下問題:Python migrations.AlterIndexTogether方法的具體用法?Python migrations.AlterIndexTogether怎麽用?Python migrations.AlterIndexTogether使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在django.db.migrations的用法示例。


在下文中一共展示了migrations.AlterIndexTogether方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _test_create_alter_foo_delete_model

# 需要導入模塊: from django.db import migrations [as 別名]
# 或者: from django.db.migrations import AlterIndexTogether [as 別名]
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"),
            ],
            [],
        ) 
開發者ID:denisenkom,項目名稱:django-sqlserver,代碼行數:16,代碼來源:test_optimizer.py

示例2: test_create_alter_index_delete_model

# 需要導入模塊: from django.db import migrations [as 別名]
# 或者: from django.db.migrations import AlterIndexTogether [as 別名]
def test_create_alter_index_delete_model(self):
        self._test_create_alter_foo_delete_model(migrations.AlterIndexTogether("Foo", [["a", "b"]])) 
開發者ID:denisenkom,項目名稱:django-sqlserver,代碼行數:4,代碼來源:test_optimizer.py

示例3: _test_alter_alter_model

# 需要導入模塊: from django.db import migrations [as 別名]
# 或者: from django.db.migrations import AlterIndexTogether [as 別名]
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,
            ],
        ) 
開發者ID:denisenkom,項目名稱:django-sqlserver,代碼行數:16,代碼來源:test_optimizer.py

示例4: test_alter_alter_index_model

# 需要導入模塊: from django.db import migrations [as 別名]
# 或者: from django.db.migrations import AlterIndexTogether [as 別名]
def test_alter_alter_index_model(self):
        self._test_alter_alter_model(
            migrations.AlterIndexTogether("Foo", [["a", "b"]]),
            migrations.AlterIndexTogether("Foo", [["a", "c"]]),
        ) 
開發者ID:denisenkom,項目名稱:django-sqlserver,代碼行數:7,代碼來源:test_optimizer.py

示例5: test_create_alter_index_field

# 需要導入模塊: from django.db import migrations [as 別名]
# 或者: from django.db.migrations import AlterIndexTogether [as 別名]
def test_create_alter_index_field(self):
        self._test_create_alter_foo_field(migrations.AlterIndexTogether("Foo", [["a", "b"]])) 
開發者ID:denisenkom,項目名稱:django-sqlserver,代碼行數:4,代碼來源:test_optimizer.py

示例6: test_alter_index_together_remove

# 需要導入模塊: from django.db import migrations [as 別名]
# 或者: from django.db.migrations import AlterIndexTogether [as 別名]
def test_alter_index_together_remove(self):
        operation = migrations.AlterIndexTogether("Pony", None)
        self.assertEqual(operation.describe(), "Alter index_together for Pony (0 constraint(s))") 
開發者ID:denisenkom,項目名稱:django-sqlserver,代碼行數:5,代碼來源:test_operations.py

示例7: test_alter_index_together

# 需要導入模塊: from django.db import migrations [as 別名]
# 或者: from django.db.migrations import AlterIndexTogether [as 別名]
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")}}) 
開發者ID:nesdis,項目名稱:djongo,代碼行數:29,代碼來源:test_operations.py


注:本文中的django.db.migrations.AlterIndexTogether方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。