Database migrations
This commit is contained in:
13
AGENTS.md
13
AGENTS.md
@@ -1 +1,14 @@
|
||||
Use the version of Python/Pytest in the .venv directory when attempting to run commands, as that's where the pip dependencies (and pytest) are installed.
|
||||
|
||||
## Database migrations
|
||||
|
||||
Schema changes use Alembic (migrations live in `src/pirats/migrations/`, shipped inside the package). The app applies them automatically at startup via `pirats.database.run_migrations()`; databases predating Alembic are normalized and stamped at the `0001` baseline first.
|
||||
|
||||
After editing `src/pirats/models.py`, generate a migration and sanity-check it:
|
||||
|
||||
```
|
||||
.venv/bin/alembic revision --autogenerate -m "describe the change"
|
||||
.venv/bin/alembic upgrade head # or just start the app
|
||||
```
|
||||
|
||||
Do NOT add ad-hoc `ALTER TABLE` statements to `database.py` — that legacy list exists only to upgrade pre-Alembic databases to the baseline and must not grow.
|
||||
|
||||
Reference in New Issue
Block a user