Fix SQL migration error

This commit is contained in:
2026-06-15 10:38:41 -07:00
parent e4c78391fc
commit c03efd4a65
2 changed files with 5 additions and 2 deletions

View File

@@ -11,6 +11,9 @@ After editing `src/pirats/models.py`, generate a migration and sanity-check it:
.venv/bin/alembic upgrade head # or just start the app
```
**Note on adding NOT NULL columns in SQLite:**
SQLite does not support adding a `NOT NULL` column without a default value to an existing table. When Alembic auto-generates a migration that adds a `nullable=False` column, you MUST manually edit the migration to include `server_default="..."` in the `sa.Column` definition (e.g., `server_default=""` for strings) before applying it. Otherwise, the migration will crash with `Cannot add a NOT NULL column with default value NULL`.
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.
## Learning during testing