Description
The play_history.play_status column currently accepts any text value, although the bot only intentionally uses:
queued
playing
completed
skipped
Add validation to prevent typos or future code paths from storing unsupported statuses.
Proposed changes
- Add a SQLite
CHECK constraint:
CHECK (play_status IN ('queued', 'playing', 'completed', 'skipped'))
- Validate status values in
DatabaseManager.update_play_status() and raise a clear error for invalid values.
- Audit existing databases for unexpected values before migration.
- Rebuild the table to apply the constraint, since SQLite cannot add it directly to an existing column.
- Preserve all existing data, indexes, defaults, and column types during migration.
- Add tests confirming that valid statuses are accepted and invalid statuses are rejected.
Acceptance criteria
- Existing databases migrate without losing valid data.
- All four supported statuses continue to work.
- Invalid status values cannot be inserted or assigned.
- Existing indexes are recreated after migration.
- The migration handles unexpected legacy values safely and reports them clearly.
Description
The
play_history.play_statuscolumn currently accepts any text value, although the bot only intentionally uses:queuedplayingcompletedskippedAdd validation to prevent typos or future code paths from storing unsupported statuses.
Proposed changes
CHECKconstraint:DatabaseManager.update_play_status()and raise a clear error for invalid values.Acceptance criteria