tortoise / aerich

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

Without CLI #141

Closed Olegt0rr closed 3 years ago

Olegt0rr commented 3 years ago

Please make ability to use aerich without CLI

I want to run it as an external library from my code

  1. Init my app config
  2. import aerich and run upgrade with params from config
  3. init tortiose
marcoaaguiar commented 3 years ago

I would like this feature too. In the mean time I'm using:

subprocess.check_output([*"poetry run aerich init-db".split()])
Olegt0rr commented 3 years ago

I'm calling it similar way, but can't apply it on apps with complex dynamic configuration.

By the way, you may change your list, asterisk and .split to shell=True param :)

manzato commented 3 years ago

@long2ice I'm interested in this feature, so I'd like to take a crack at it. Do you think it is in the interest of the project? Do you think it would be difficult to do/maintain? I'd like to get a flow similar to what I had with django, where I can run migrations before my tests, from within the code.

long2ice commented 3 years ago

There maybe much work to do, if you want you can give a try.

manzato commented 3 years ago

FYI: I figured that the reason I wanted to have migrations being run from inside the app is to have "system data" such as basic settings on my config table, so I wrote a very simple project called https://github.com/ekumenlabs/tortoise-data-migration