Skip to content

Add database constraint and application validation for play_status #10

Description

@jackmanuel

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions