import Dexie from 'dexie'

/**
 * Local IndexedDB snapshot — written by SSE events and full GETs.
 * Read-only in Emergency Mode when the server is unreachable.
 */
const db = new Dexie('pos_snapshot')

db.version(1).stores({
  tables:  'id, group_id, is_active',
  orders:  'id, table_id, status',
  offline_payments: '++localId, uuid, synced',
})

db.version(2).stores({
  tables:  'id, group_id, is_active',
  orders:  'id, table_id, status',
  offline_payments: '++localId, uuid, synced',
  products:    'id, category_id, is_available',
  categories:  'id, parent_id',
})

export default db
