Skip to content

Commit 062c763

Browse files
committed
fixing a bug in MigrationManager._run_add_columns
The Table metaclass wasn't being called on columns, so the ForeignKeyMeta wasn't being setup correctly on ForeignKey columns.
1 parent 2f513e4 commit 062c763

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

piccolo/apps/migrations/auto/migration_manager.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,8 +511,15 @@ async def _run_add_columns(self, backwards=False):
511511
AddColumnClass
512512
] = self.add_columns.for_table_class_name(table_class_name)
513513

514+
# Define the table, with the columns, so the metaclass
515+
# sets up the columns correctly.
514516
_Table: t.Type[Table] = type(
515-
add_columns[0].table_class_name, (Table,), {}
517+
add_columns[0].table_class_name,
518+
(Table,),
519+
{
520+
add_column.column._meta.name: add_column.column
521+
for add_column in add_columns
522+
},
516523
)
517524
_Table._meta.tablename = add_columns[0].tablename
518525

0 commit comments

Comments
 (0)