File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
tests/apps/migrations/auto Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -146,6 +146,36 @@ def test_add_column(self):
146146 response = self .run_sync ("SELECT * FROM manager;" )
147147 self .assertEqual (response , [{"id" : 1 , "name" : "Dave" }])
148148
149+ @postgres_only
150+ def test_add_column_with_index (self ):
151+ """
152+ Test adding a column with an index to a MigrationManager.
153+ """
154+ manager = MigrationManager ()
155+ manager .add_column (
156+ table_class_name = "Manager" ,
157+ tablename = "manager" ,
158+ column_name = "email" ,
159+ column_class_name = "Varchar" ,
160+ params = {
161+ "length" : 100 ,
162+ "default" : "" ,
163+ "null" : True ,
164+ "primary" : False ,
165+ "key" : False ,
166+ "unique" : True ,
167+ "index" : True ,
168+ },
169+ )
170+ index_name = Manager ._get_index_name (["email" ])
171+
172+ asyncio .run (manager .run ())
173+ self .assertTrue (index_name in Manager .indexes ().run_sync ())
174+
175+ # Reverse
176+ asyncio .run (manager .run_backwards ())
177+ self .assertTrue (index_name not in Manager .indexes ().run_sync ())
178+
149179 @postgres_only
150180 def test_add_foreign_key_self_column (self ):
151181 """
You can’t perform that action at this time.
0 commit comments