Describe the bug
After creating the migration with the model containing foreign key to itself, migration is failing due to KeyError. After quick investigation, the exact line containing the bug is ForeignKeyField(model=migrator.orm["model"], ...). During execution of this code, "model" is not yet added to migrator.orm dict. Instead, the call should look like: ForeignKeyField(model="self", ...). After changing it the proposed way, migration has completed successfully.
To Reproduce
Steps to reproduce the behavior:
Write a model containing a self-referencing foreign key:
class TestModel(Model):
parent = ForeignKeyField("self")
Create a migration
Run the migration
Expected behavior
Migration should pass correctly.
Desktop (please complete the following information):
Describe the bug After creating the migration with the model containing foreign key to itself, migration is failing due to
KeyError
. After quick investigation, the exact line containing the bug isForeignKeyField(model=migrator.orm["model"], ...)
. During execution of this code,"model"
is not yet added tomigrator.orm
dict. Instead, the call should look like:ForeignKeyField(model="self", ...)
. After changing it the proposed way, migration has completed successfully.To Reproduce Steps to reproduce the behavior:
Expected behavior Migration should pass correctly.
Desktop (please complete the following information):