piccolo-orm/piccolo

Adding a self referencing foreign key to an existing table which has a custom primary key

Closed this issue · 0 comments

This is a real edge case that I just came across.

If you have this table:

class MyTable(Table):
    id = UUID(primary_key=True)

And modify it to this:

class MyTable(Table):
    id = UUID(primary_key=True)
    fk = ForeignKey("self")

The auto migration can fail, because it doesn't know to create the new foreign key column as a UUID type.