Skip to content

Commit

Permalink
changing column types can work in reverse
Browse files Browse the repository at this point in the history
  • Loading branch information
dantownsend committed Feb 13, 2021
1 parent f7d8147 commit 3859bfa
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions piccolo/apps/migrations/auto/migration_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,20 @@ async def _run_alter_columns(self, backwards=False):
)
column_name = alter_column.column_name

###############################################################

# Change the column type if possible
column_class = alter_column.column_class
old_column_class = alter_column.old_column_class
column_class = (
alter_column.old_column_class
if backwards
else alter_column.column_class
)
old_column_class = (
alter_column.column_class
if backwards
else alter_column.old_column_class
)

if (old_column_class is not None) and (
column_class is not None
):
Expand All @@ -361,6 +372,8 @@ async def _run_alter_columns(self, backwards=False):
old_column=old_column, new_column=new_column
)

###############################################################

null = params.get("null")
if null is not None:
await _Table.alter().set_null(
Expand Down

0 comments on commit 3859bfa

Please sign in to comment.