tortoise / aerich

A database migrations tool for TortoiseORM, ready to production.
https://github.com/tortoise/aerich
Apache License 2.0
820 stars 94 forks source link

KeyError: 'src_folder' after upgrading aerich to 0.5.4 #176

Closed yusukefs closed 3 years ago

yusukefs commented 3 years ago

When I tried to upgrade aerich from 0.5.3 to 0.5.4 and use it, I faced an error below.

Traceback (most recent call last):
  File "/usr/local/bin/aerich", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/site-packages/aerich/cli.py", line 317, in main
    cli()
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1256, in invoke
    Command.invoke(self, ctx)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/aerich/cli.py", line 41, in wrapper
    loop.run_until_complete(f(*args, **kwargs))
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.8/site-packages/aerich/cli.py", line 77, in cli
    src_folder = parser[name]["src_folder"]
  File "/usr/local/lib/python3.8/configparser.py", line 1254, in __getitem__
    raise KeyError(key)
KeyError: 'src_folder'

After reading some codes, I understood the src_folder config is missing in aerich.ini in my project and could resolve the error by adding it. I thought it would be very helpful for users upgrading aerich to add, for example, raising an error that tell us to add the new option around here or having a default value on absent. What do you think is the best solution?

long2ice commented 3 years ago

Yes, we can provide a default value, could you give a PR?

yusukefs commented 3 years ago

Yes, I will open a PR for that!

kingb commented 3 years ago

Is it possible to make a quick new 0.5.5 release with this fix as we're getting the same error?