peewee_migrate2
peewee_migrate2 copied to clipboard
Migration failed, keyerror, migrator.orm is empty
I'm trying to create my first migration, however, the sorting mechanism is not ordering correctly the table's creation raising KeyError, I think the error lies on peewee_migrate/auto.py:133
, the function sort_models from peewee is not ordering correctly.
traceback:
root@c5f155f1ac41:/app$ pw_migrate migrate
Starting migrations
Migrate "001_auto_20210705_1356"
Migration failed: 001_auto_20210705_1356
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/peewee_migrate/router.py", line 157, in run_one
migrate(migrator, self.database, fake=fake)
File "<string>", line 166, in migrate
File "<string>", line 183, in ClientTelephone
KeyError: 'telephone_types'
Traceback (most recent call last):
File "/usr/local/bin/pw_migrate", line 8, in <module>
sys.exit(cli())
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/peewee_migrate/cli.py", line 107, in migrate
migrations = router.run(name, fake=fake)
File "/usr/local/lib/python3.9/site-packages/peewee_migrate/router.py", line 186, in run
self.run_one(mname, migrator, fake=fake, force=fake)
File "/usr/local/lib/python3.9/site-packages/peewee_migrate/router.py", line 157, in run_one
migrate(migrator, self.database, fake=fake)
File "<string>", line 166, in migrate
File "<string>", line 183, in ClientTelephone
KeyError: 'telephone_types'
The original package has the same issue: https://github.com/klen/peewee_migrate/issues/163
Can you post your models which trigger this error?