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

Added config option to specify source folder #166

Closed spacemanspiff2007 closed 3 years ago

spacemanspiff2007 commented 3 years ago

Added an configuration option to specify the path of the source folder. This will make aerich work with various folder structures (e.g. ./src/MyPythonModule) Additionally this will try to import in init and show the user the error message on failure.

spacemanspiff2007 commented 3 years ago

This will also fix/prevent e.g. #95

spacemanspiff2007 commented 3 years ago

@long2ice Could you take a look at this? I am currently unable to deploy/use aerich. With this PR it works fine

long2ice commented 3 years ago

Your case maybe point here https://github.com/tortoise/aerich/blob/dev/aerich/cli.py#L297

spacemanspiff2007 commented 3 years ago

Yes, but with the additional arg I can configure it for both the deployment and local use without having to patch aerich. If you could merge/review the pr it would be really great!

long2ice commented 3 years ago

Maybe put it in aerich.ini is better, which is a global config

spacemanspiff2007 commented 3 years ago

Maybe put it in aerich.ini is better, which is a global config

This pr does both! It allows configuration through command line arg and through aerich.ini.

[aerich]
tortoise_orm = MyApp.db_models._db.TORTOISE_ORM_CFG
location = ./migrations
src_folder = ./src

[deploy]
tortoise_orm = MyApp.db_models._db.TORTOISE_ORM_CFG
location = ./migrations
src_folder = ./app
spacemanspiff2007 commented 3 years ago

@long2ice I reformatted the changed files with black, so I hope your ci runs now properly. I hope this is okay. Otherwise I can revert these changes. Please let me know what you think

spacemanspiff2007 commented 3 years ago

Hmm, still fails. 😞

I ran black -l 100 -t py38 aerich/. Can you provide me with a hint how I can fix the failing ci check?

spacemanspiff2007 commented 3 years ago

@long2ice I think I got it. In the pyproject you specified an older black version. Now it should run fine! 👍

long2ice commented 3 years ago

Thanks!

spacemanspiff2007 commented 3 years ago

Would you mind making a release so I use the official package for the deployment?