Skip to content

Commit 3859bfa

Browse files
committed
changing column types can work in reverse
1 parent f7d8147 commit 3859bfa

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

piccolo/apps/migrations/auto/migration_manager.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,20 @@ async def _run_alter_columns(self, backwards=False):
340340
)
341341
column_name = alter_column.column_name
342342

343+
###############################################################
344+
343345
# Change the column type if possible
344-
column_class = alter_column.column_class
345-
old_column_class = alter_column.old_column_class
346+
column_class = (
347+
alter_column.old_column_class
348+
if backwards
349+
else alter_column.column_class
350+
)
351+
old_column_class = (
352+
alter_column.column_class
353+
if backwards
354+
else alter_column.old_column_class
355+
)
356+
346357
if (old_column_class is not None) and (
347358
column_class is not None
348359
):
@@ -361,6 +372,8 @@ async def _run_alter_columns(self, backwards=False):
361372
old_column=old_column, new_column=new_column
362373
)
363374

375+
###############################################################
376+
364377
null = params.get("null")
365378
if null is not None:
366379
await _Table.alter().set_null(

0 commit comments

Comments
 (0)