Skip to content

Commit 3fce612

Browse files
committed
making sure the right column params are used when reversing a migration
1 parent 3859bfa commit 3fce612

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

piccolo/apps/migrations/auto/migration_manager.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -333,12 +333,18 @@ async def _run_alter_columns(self, backwards=False):
333333
_Table._meta.tablename = alter_columns[0].tablename
334334

335335
for alter_column in alter_columns:
336+
336337
params = (
337338
alter_column.old_params
338339
if backwards
339340
else alter_column.params
340341
)
341-
column_name = alter_column.column_name
342+
343+
old_params = (
344+
alter_column.params
345+
if backwards
346+
else alter_column.old_params
347+
)
342348

343349
###############################################################
344350

@@ -358,13 +364,11 @@ async def _run_alter_columns(self, backwards=False):
358364
column_class is not None
359365
):
360366
if old_column_class != column_class:
361-
old_column = old_column_class(
362-
**alter_column.old_params
363-
)
367+
old_column = old_column_class(**old_params)
364368
old_column._meta._table = _Table
365369
old_column._meta._name = alter_column.column_name
366370

367-
new_column = column_class(**alter_column.params)
371+
new_column = column_class(**params)
368372
new_column._meta._table = _Table
369373
new_column._meta._name = alter_column.column_name
370374

@@ -374,6 +378,8 @@ async def _run_alter_columns(self, backwards=False):
374378

375379
###############################################################
376380

381+
column_name = alter_column.column_name
382+
377383
null = params.get("null")
378384
if null is not None:
379385
await _Table.alter().set_null(

0 commit comments

Comments
 (0)