(self)
| 5255 | |
| 5256 | @unittest.skipUnless(connection.vendor == "postgresql", "PostgreSQL specific") |
| 5257 | def test_alter_field_add_index_to_textfield(self): |
| 5258 | # Create the table and verify no initial indexes. |
| 5259 | with connection.schema_editor() as editor: |
| 5260 | editor.create_model(Note) |
| 5261 | self.assertEqual(self.get_constraints_for_column(Note, "info"), []) |
| 5262 | # Alter to add db_index=True and create 2 indexes. |
| 5263 | old_field = Note._meta.get_field("info") |
| 5264 | new_field = TextField(db_index=True) |
| 5265 | new_field.set_attributes_from_name("info") |
| 5266 | with connection.schema_editor() as editor: |
| 5267 | editor.alter_field(Note, old_field, new_field, strict=True) |
| 5268 | self.assertEqual( |
| 5269 | self.get_constraints_for_column(Note, "info"), |
| 5270 | ["schema_note_info_4b0ea695", "schema_note_info_4b0ea695_like"], |
| 5271 | ) |
| 5272 | # Remove db_index=True to drop both indexes. |
| 5273 | with connection.schema_editor() as editor: |
| 5274 | editor.alter_field(Note, new_field, old_field, strict=True) |
| 5275 | self.assertEqual(self.get_constraints_for_column(Note, "info"), []) |
| 5276 | |
| 5277 | @unittest.skipUnless(connection.vendor == "postgresql", "PostgreSQL specific") |
| 5278 | def test_alter_field_add_unique_to_charfield_with_db_index(self): |
nothing calls this directly
no test coverage detected