-- Per-user, per-game level progress for ordered single-player puzzle games
-- (Rush Hour and future Logic & Puzzle titles).
--
-- A single integer `levels_completed` records the highest contiguous level the
-- user has cleared. Because levels must be played in order, the next playable
-- level is always levels_completed + 1.

CREATE TABLE puzzle_progress (
  user_id          INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
  slug             TEXT    NOT NULL,
  levels_completed INTEGER NOT NULL DEFAULT 0,
  updated_at       TEXT    NOT NULL DEFAULT (datetime('now')),
  PRIMARY KEY (user_id, slug)
);
