Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration failed, keyerror, migrator.orm is empty #163

Open
simse opened this issue Oct 17, 2019 · 4 comments
Open

Migration failed, keyerror, migrator.orm is empty #163

simse opened this issue Oct 17, 2019 · 4 comments

Comments

@simse
Copy link

simse commented Oct 17, 2019

I'm trying to add a field using the following code:
migrator.add_fields('Script', 'cron')

This is the ouput:
Migration failed: 001_add_cron Traceback (most recent call last): File "/mnt/c/Users/Simon Sorensen/Documents/GitHub/chronos/.venv/lib/python3.6/site-packages/peewee_migrate/router.py", line 153, in run_one migrate(migrator, self.database, fake=fake) File "<string>", line 39, in migrate File "/mnt/c/Users/Simon Sorensen/Documents/GitHub/chronos/.venv/lib/python3.6/site-packages/peewee_migrate/migrator.py", line 105, in wrapper return method(migrator, migrator.orm[model], *args, **kwargs) KeyError: 'Script' Traceback (most recent call last): File "chronos.py", line 9, in <module> from chronos.runtime import * File "/mnt/c/Users/Simon Sorensen/Documents/GitHub/chronos/chronos/runtime.py", line 10, in <module> import chronos.metadata File "/mnt/c/Users/Simon Sorensen/Documents/GitHub/chronos/chronos/metadata.py", line 57, in <module> router.run() File "/mnt/c/Users/Simon Sorensen/Documents/GitHub/chronos/.venv/lib/python3.6/site-packages/peewee_migrate/router.py", line 182, in run self.run_one(mname, migrator, fake=fake, force=fake) File "/mnt/c/Users/Simon Sorensen/Documents/GitHub/chronos/.venv/lib/python3.6/site-packages/peewee_migrate/router.py", line 153, in run_one migrate(migrator, self.database, fake=fake) File "<string>", line 39, in migrate File "/mnt/c/Users/Simon Sorensen/Documents/GitHub/chronos/.venv/lib/python3.6/site-packages/peewee_migrate/migrator.py", line 105, in wrapper return method(migrator, migrator.orm[model], *args, **kwargs) KeyError: 'Script'

It looks like migrator.orm is empty. What am I doing wrong?

@simse
Copy link
Author

simse commented Oct 17, 2019

Prettier output: https://pastebin.com/Dtnfey8S

@revolter
Copy link

Same issue

@dmiwell
Copy link
Contributor

dmiwell commented Jul 6, 2020

Looks like the issue happens because of some imports. I know that there is an issue with relative imports, so it fails while compiling migration file code with something like KeyError: "'__name__' not in globals".

Script key is not something from the pacakge code, so I assume the issue is some combination of imports and compilation of migration code.

@simse make sure your code is fine. I'm not sure if import * could be executed fine.

Probably the related thing to start from is peewee_migrate.router.Router.read

@dmiwell
Copy link
Contributor

dmiwell commented Jul 6, 2020

@revolter this package seems to not being supported now, so if you are interested in it check https://github.com/spumer/peewee_migrate2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants