# aiops

Integrate AI for TiDBCloud Ops Portal.

## Setup

1. Install [uv](https://docs.astral.sh/uv/getting-started/installation/) which is used to manage python packages.

2. Run `make install` to sync packages (via `uv sync`) and install Alembic cli helper.

3. Setup the config file `config.yaml` which is similar to `config-example.yaml`.

4. Setup `.env` file which is similar to `.env.example`.


## Migrate

We use [alembic](https://github.com/sqlalchemy/alembic) to run database schema migrations.

After modifing orm classes, do the following to generate a migration script.

1. Setup the config file `config.yaml` which is similar to `config-example.yaml`.

    The `alembic` will use the database of the `config.yaml` to generate migration scripts.

2. Run the command to generate.

    ```bash
    AIOPS_CONFIG_FILE=config.yaml uv run alembic revision --autogenerate -m "${description}"
    ```

3. Check and modify the migration script as you needed.

    ```bash
    cat ./aiops/migrate/versions/${revision}_${description}.py
    ```
