8000 Schema clean-up for the next migration · Issue #305 · alexbeeken/skrongle-mini · GitHub
[go: up one dir, main page]

Skip to content

Schema clean-up for the next migration #305

Backlog

Description

@alexbeeken

Rules held only in code, and columns nothing uses. None is urgent; do them together the next time the schema changes.

Rules:

  • users.email is nullable with a non-unique index. Uniqueness rests on profile::email_taken and an ORDER BY id LIMIT 1 in auth::CREDENTIALS_SQL. Add a unique index on lower(email).
  • Only jobs.state has a CHECK. Unchecked text: courses.state, courses.source, lesson_passes.*_via, users.two_factor, course_ai_run_files.side, api_tokens.kind. CourseState::parse maps anything unknown to Ready (src/courses.rs:499). CHECKs need a table rebuild, so add each when its table is rebuilt for another reason.
  • course_id TEXT NOT NULL DEFAULT 'spanish' on quiz_history, game_scores and game_activity. Every insert supplies the column; drop the defaults.

Unused:

  • users.delete_at and idx_users_delete_at: never read or written.
  • jobs.priority: never written, read only in an ORDER BY (src/jobs.rs:164).
  • Written and never read: lesson_passes.updated_at, journey_progress.updated_at, lesson_notes.updated_at, courses.created_at, course_shares.created_at. Decide per column: show it somewhere or drop it. (users.age_confirmed and signup_invites.used_by are records and should stay.)
  • users.email_verified_at: in a release only proxy sign-in sets it, and it shows as a ✓ on the profile. Probably drop it with the badge.

Orphans: delete_course keeps every per-course progress row "so a course re-added under its id finds them", but ids carry a random suffix (src/courses.rs:1006), so nothing ever finds them. Delete them in delete_course, inside a transaction, or list them in docs/data-inventory.md as kept.

Silent defaults on our own JSON columns: serde_json::from_str(s).unwrap_or_default() for review exclusions and edits (src/review.rs:67,142), check notes (src/ai/check.rs:54) and the translate plan (src/translate.rs:45). After a format change, "left out of the review" becomes "nothing left out" without a word. Log a warning at those four sites.

From the code review of 24 November 2026. Line numbers are as of 0.5.0 (2547b36).

Activity

  1. added
    review
    on Nov 24, 2026
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

    review

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0