Fix SQL migration error
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user