tortoise / aerich

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

Unrecognized arguments #130

Open Olegt0rr opened 3 years ago

Olegt0rr commented 3 years ago

Strange behaviour with custom configs

Command

aerich -n migration-local -c res/aerich/aerich.ini upgrade

Exception

usage: aerich [-h] [-c C]
aerich: error: unrecognized arguments: -n migration-local upgrade

Tree

entrypoint
├── res
│   ├── aerich
│   │   ├── aerich.ini
│   │   ├── aerich_cfg_local.py
│   │   └── migrations
│   │       └── models
│   │           └── 0_20210315180332_init.sql

Files

aerich.ini

[migration-local]
tortoise_orm = res.aerich.aerich_cfg_local.TORTOISE_ORM
location = ./res/aerich/migrations

aerich_cfg_local.py

POSTGRES_HOST = "localhost"
POSTGRES_PORT = 5432
POSTGRES_PASSWORD = "pgpassword"
POSTGRES_USER = "pguser"
POSTGRES_DB = "pgdb"

POSTGRES_URI = (
    f"postgres://{POSTGRES_USER}:{POSTGRES_PASSWORD}@"
    f"{POSTGRES_HOST}:{POSTGRES_PORT}/{POSTGRES_DB}"
)

TORTOISE_ORM = {
    "connections": {"default": POSTGRES_URI},
    "apps": {
        "models": {
            "models": ["app.models", "aerich.models"],
            "default_connection": "default",
        },
    },
}