import Dexie, { type Table } from 'dexie'; import type { PicletInstance, Encounter, GameState, TrainerScanProgress } from './schema'; export class PicletDatabase extends Dexie { // Game tables picletInstances!: Table; encounters!: Table; gameState!: Table; trainerScanProgress!: Table; constructor() { super('PicletGameDB'); // Version 1: Legacy monsters table (removed in v5) // Version 2: Legacy monsters table with imageData (removed in v5) // Version 3: Legacy monsters table with stats (removed in v5) // Version 4: Add new game tables with legacy monsters this.version(4).stores({ monsters: '++id, name, createdAt', picletInstances: '++id, typeId, nickname, isInRoster, rosterPosition, caughtAt', encounters: '++id, type, createdAt', gameState: '++id, lastPlayed' }); // Version 5: Remove legacy monsters table this.version(5).stores({ picletInstances: '++id, typeId, nickname, isInRoster, rosterPosition, caughtAt', encounters: '++id, type, createdAt', gameState: '++id, lastPlayed' }); // Version 6: Add trainer scanning progress table this.version(6).stores({ picletInstances: '++id, typeId, nickname, isInRoster, rosterPosition, caughtAt', encounters: '++id, type, createdAt', gameState: '++id, lastPlayed', trainerScanProgress: 'imagePath, trainerName, status, completedAt' }); // Version 7: Move schema updated to include complete Move data (priority, flags, effects) // No schema changes needed - just expanded interfaces, data will be preserved this.version(7).stores({ picletInstances: '++id, typeId, nickname, isInRoster, rosterPosition, caughtAt', encounters: '++id, type, createdAt', gameState: '++id, lastPlayed', trainerScanProgress: 'imagePath, trainerName, status, completedAt' }); } } export const db = new PicletDatabase();