Metadata-Version: 2.3
Name: pinta-db
Version: 0.1.0
Summary: Database component of the elevation production system
Requires-Dist: geoalchemy2>=0.18.4
Requires-Dist: sqlmodel>=0.0.37
Requires-Dist: uv~=0.11.1 ; extra == 'build'
Requires-Dist: alembic>=1.18.4 ; extra == 'migrations'
Requires-Dist: geoalchemy2[shapely] ; extra == 'shapely'
Requires-Dist: numpy>=2 ; extra == 'shapely'
Requires-Python: >=3.12
Provides-Extra: build
Provides-Extra: migrations
Provides-Extra: shapely
Description-Content-Type: text/markdown

# Database component

Install all dependencies and extras with `uv sync --all-extras`.

## Creating migrations

To create migrations modify database models first.
Make sure to have the models imported in [env.py](./migrations/env.py)
by adding them into [models.all](./src/pinta_db/models/all.py) module.

After models have been modified, run:

```bash
uv run alembic revision --autogenerate -m "Migration description" --rev-id="migration_id"
```

This command will generate a new migration file based on the changes made to the models.

Check the created migration file and make sure it is correct and remove Alembic autogenerated
comments from the top and bottom of the functions. Remember to commit it in the repository.

## Running migrations

To run migrations in development, in root of the project run:

```bash
docker-compose run --rm ansible
```

or `make infra-full`.

If you want to skip database initialization, just run `make migrations`.

In development, you can also run migrations manually by running:

```bash
uv run alembic upgrade head
```

But this does not run migrations to test databases.
