-- 0005_games.sql — per-user save states for emulated games. -- -- Save states are user data, not media: two people playing the same ROM keep -- their own saves. Keyed by (user, item, slot) so a game can have several save -- slots, the same way a console memory card would. CREATE TABLE game_saves ( user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE, item_id INTEGER NOT NULL REFERENCES media_items(id) ON DELETE CASCADE, slot TEXT NOT NULL DEFAULT 'default', data BLOB NOT NULL, size INTEGER NOT NULL DEFAULT 0, updated_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now')), PRIMARY KEY (user_id, item_id, slot) ); CREATE INDEX idx_game_saves_item ON game_saves(item_id);