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

Compatibility for apps with CLI #123

Closed Olegt0rr closed 3 years ago

Olegt0rr commented 3 years ago

To read POSTGRES_URI my app uses CLI with -c flag (to provide config path) How can I set up aerich to prevent CLI conflicts?

Version

aerich==0.5.0 As described, I've dropped all database, removed migrations folder.

Run command

aerich init-db

Result

usage: aerich [-h] [-c C]
aerich: error: unrecognized arguments: init-db

Config

aerich.ini

[aerich]
tortoise_orm = app.config.TORTOISE_ORM
location = ./migrations

app.config.TORTOISE_ORM

TORTOISE_ORM = {
    "connections": {"default":POSTGRES_URI},
    "apps": {
        "models": {
            "models": ["app.models", "aerich.models"],
            "default_connection": "default",
        },
    },
}
long2ice commented 3 years ago

So strange

Olegt0rr commented 3 years ago

So strange

It was affected by my app. app.config imports cli to handle custom cfg -c config.yml for my app. So cli and aerich conflicts with each other.

It would be great if you know how to isolate aerich from app's cli

Olegt0rr commented 3 years ago

@long2ice is there any way to pass args for app module through aerich? In my case: provide config path for app via -c

long2ice commented 3 years ago

Sorry I don't know what do you mean

Olegt0rr commented 3 years ago

To run my app I use

python -m my_app -c config.yml

So, my app always waits for -c config.yml

When aerich trying to work with my app, it didn't pass -c config.yml, so my app can't get my config.

long2ice commented 3 years ago

What about split config file from you app?